HI
IIUC I can get all terms of a particular field of an index with
IndexReader reader = DirectoryReader.open(„index_directory");
List<LeafReaderContext> list = reader.leaves();
for (LeafReaderContext lrc : list) {
Terms terms = lrc.reader().terms(„field_name");
if (terms != null) {
TermsEnum termsEnum = terms.iterator();
BytesRef term = null;
while ((term = termsEnum.next()) != null) {
System.out.println("Term: " + term.utf8ToString());
}
}
}
reader.close();
But how I can get all terms of a particular field of a particular document?
Thanks
Michael
P.S.: Btw, does it make sense to update the Lucene FAQ
https://cwiki.apache.org/confluence/display/lucene/lucenefaq#LuceneFAQ-HowdoIretrieveallthevaluesofaparticularfieldthatexistswithinanindex,acrossalldocuments?
with the code above?
I can do this, but want to make sure, that I don’t update it in a wrong way.
IIUC I can get all terms of a particular field of an index with
IndexReader reader = DirectoryReader.open(„index_directory");
List<LeafReaderContext> list = reader.leaves();
for (LeafReaderContext lrc : list) {
Terms terms = lrc.reader().terms(„field_name");
if (terms != null) {
TermsEnum termsEnum = terms.iterator();
BytesRef term = null;
while ((term = termsEnum.next()) != null) {
System.out.println("Term: " + term.utf8ToString());
}
}
}
reader.close();
But how I can get all terms of a particular field of a particular document?
Thanks
Michael
P.S.: Btw, does it make sense to update the Lucene FAQ
https://cwiki.apache.org/confluence/display/lucene/lucenefaq#LuceneFAQ-HowdoIretrieveallthevaluesofaparticularfieldthatexistswithinanindex,acrossalldocuments?
with the code above?
I can do this, but want to make sure, that I don’t update it in a wrong way.