Hi Mikhail
Thank you very much for your feedback!
I have found various examples for the first option when running a query,
e.g.
https://howtodoinjava.com/lucene/lucene-search-highlight-example/
but don't understand how to implement the second option, resp. how to
get the extracted terms of a document field independent of a query?
Can you maybe give a code example?
Thanks
Michael
Am 12.11.23 um 18:46 schrieb Mikhail Khludnev:
Hello,
This is what highlighters do. There are two options:
- index termVectors, obtain them in search time.
- obtain the stored field value, analyse it again, get all terms.
Good Luck
On Sun, Nov 12, 2023 at 7:47 PM Michael Wechner <[email protected]>
wrote:
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]