To return the position offset information along with the highlighted snippet we created a CustomSolrHighlihter(attached). Depending on the type of query the custom highlighter returns the position offsets information.
- Non-phrase query: Using FieldTermStack we return the term position offset for the terms in the query.
- Phrase query: Using the WeightedFragInfo.fragInfos we return the term position offset for the terms in the query.
But currently the Toffs(Term offsets) class only stores the start and end offset and so we updated it so that it would store the position information as well.
Answers to your questions:
- What is the position offset? Isn't it just a position?
Yes, it is just the position.
<str>un of <strong class="highlight">divine knowledge</strong> and understanding, and become the recipients of a grace that is infinite and </str>
P.S. In order to able to override doHighlightingByFastVectorHighlighter() method in CustomSolrHighlighter we had to change the access modifier for alternateField() and getSolrFragmentsBuilder() to protected.