开发者

Lucene TermFrequenciesVector

开发者 https://www.devze.com 2023-02-05 20:14 出处:网络
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 comme

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消