【问题标题】:Find list of terms indexed by Lucene查找 Lucene 索引的术语列表
【发布时间】:2012-06-21 23:00:54
【问题描述】:

是否可以将 Lucene 索引中的所有术语列表提取为字符串列表?我在文档中找不到该功能。谢谢!

【问题讨论】:

    标签: lucene


    【解决方案1】:

    在 Lucene 4(和 5)中:

     Terms terms = SlowCompositeReaderWrapper.wrap(directoryReader).terms("field"); 
    

    编辑:

    现在这似乎是“正确”的方式(Lucene 6 及更高版本):

    LuceneDictionary ld = new LuceneDictionary( indexReader, "field" );
    BytesRefIterator iterator = ld.getWordsIterator();
    BytesRef byteRef = null;
    while ( ( byteRef = iterator.next() ) != null )
    {
        String term = byteRef.utf8ToString();
    }
    

    【讨论】:

    • 假设字段名称是 "field". 在 Jackrabbit 中是 "_:FULLTEXT".
    • @RobAu SlowCompositeReaderWrapper 现在在 6.1.0 中已弃用。你知道在 6.4.1 中怎么做吗?
    • Lucene 团队似乎养成了一个非常坏的习惯,即在不更新 Javadoc 以将人们指向新的方式或方法的情况下弃用某些东西!
    【解决方案2】:

    Lucene 3:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 2012-02-11
      • 1970-01-01
      • 2022-06-11
      相关资源
      最近更新 更多