【问题标题】:How to get top words by lucene index and search?如何通过 lucene 索引和搜索获得热门词?
【发布时间】:2013-10-10 11:43:23
【问题描述】:

我使用 lucene 库来创建索引和搜索。但现在我想获得前 30 个单词是我文本中出现的大部分单词。我能做什么?

【问题讨论】:

    标签: java search lucene indexing


    【解决方案1】:

    在 SO 中的快速搜索让我知道:Get highest frequency terms from Lucene index

    这对你有用吗?听起来像完全相同的问题..

    【讨论】:

      【解决方案2】:

      如果你使用的是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 对象中,您可以获得频率、字段名称和文本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-06
        • 2014-01-01
        • 1970-01-01
        • 2011-07-16
        • 2012-10-22
        相关资源
        最近更新 更多