Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene TermFrequenciesVector

what do I obtain if I call IndexReader.getTermFrequenciesVector(...) on an index created with TermVector.YES option?

like image 810
Antonio F. Avatar asked Mar 08 '26 21:03

Antonio F.


1 Answers

The documentation already answers this, as Xodorap notes in a comment.

The TermFreqVector object returned can retrieve which terms (words produced by your analyzer) a field contains and how many times each of those terms exists within that field.

You can cast the returned TermFreqVector to the interface TermPositionVector if you index the field using TermVector.WITH_OFFSETS, TermVector.WITH_POSITIONS or TermVector.WITH_POSITIONS_OFFSETS. This gives you access to GetTermPositions with allow you to check where in the field the term exists, and GetOffsets which allows you to check where in the original content the term originated from. The later allows, combined with Store.YES, highlighting of matching terms in a search query.

There are different contributed highlighters available under Contrib area found at the Lucene homepage.

like image 159
sisve Avatar answered Mar 11 '26 09:03

sisve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!