简体   繁体   English

如何获取lucene 4.4.0创建的索引目录中的所有术语

[英]How to get all terms in index directory created by lucene 4.4.0

I's using lucene 4.4 for index my docs, and now I want to get all terms by IndexReader. 我正在使用lucene 4.4索引我的文档,现在我想通过IndexReader获取所有术语。 In older version I used: 在旧版本中我使用:

IndexReader reader = new IndexReader.open(pathIndexDirectory);
TermEnum listTerm = reader.terms();

But in version 4.4 I can't do it. 但在4.4版本中我无法做到。 What can I do now ? 我现在能做什么 ?

So I'm using this way: 所以我用这种方式:

IndexReader reader = IndexReader.open(ramdir)
Fields fields = MultiFields.getFields(reader);
        for (String field : fields) {
            Terms terms = fields.terms(field);
            TermsEnum termsEnum = terms.iterator(null);
            int count = 0;
            while (termsEnum.next() != null) {
                count++;
            }
            System.out.println(count);
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM