Antonio F.
Antonio F.

Reputation: 421

Lucene TermFrequenciesVector

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

Upvotes: 3

Views: 176

Answers (2)

bena fein
bena fein

Reputation: 29

Or you can implement proximity or first occurrence type score contributions. Which highlighting won't help you with at all.

Upvotes: 0

sisve
sisve

Reputation: 19781

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.

Upvotes: 3

Related Questions