I's using lucene 4.4 for index my docs, and now I want to get all terms by 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. 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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With