I used lucene library to create index and search. But now I want to get top 30 words are most of the words appearing in my texts. What can I do?
Asked
Active
Viewed 1,980 times
2 Answers
1
If you are using Lucene 4.0 or later, you can use the HighFreqTerms
class, such as:
TermStats[] commonTerms = HighFreqTerms.getHighFreqTerms(reader, 30, "mytextfield");
for (TermStats commonTerm : commonTerms) {
System.out.println(commonTerm.termtext.utf8ToString()); //Or whatever you need to do with it
}
From each TermStats
object, you can get the frequencies, field name, and text.

femtoRgon
- 32,893
- 7
- 60
- 87
0
A quick search in SO got me this: Get highest frequency terms from Lucene index
Would this work for you? sounded like the exact same question..