【发布时间】:2013-10-10 11:43:23
【问题描述】:
我使用 lucene 库来创建索引和搜索。但现在我想获得前 30 个单词是我文本中出现的大部分单词。我能做什么?
【问题讨论】:
标签: java search lucene indexing
我使用 lucene 库来创建索引和搜索。但现在我想获得前 30 个单词是我文本中出现的大部分单词。我能做什么?
【问题讨论】:
标签: java search lucene indexing
在 SO 中的快速搜索让我知道:Get highest frequency terms from Lucene index
这对你有用吗?听起来像完全相同的问题..
【讨论】:
如果你使用的是Lucene 4.0或更高版本,可以使用HighFreqTerms类,如:
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
}
从每个TermStats 对象中,您可以获得频率、字段名称和文本。
【讨论】: