what do I obtain if I call IndexReader.getTermFrequenciesVector(...)
on an inde开发者_如何学编程x created with TermVector.YES
option?
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.
Or you can implement proximity or first occurrence type score contributions. Which highlighting won't help you with at all.
精彩评论