Solr Plugin that enables to store term position in highlighted snippets
Tested with Solr 8.11.2 and Java 1.8
Inspired by the work of Tricia Jenkins @ https://issues.apache.org/jira/browse/SOLR-4722
Compile with ./gradlew build
The fields must be indexed with term vectors: in schema add the following to the field definition termVectors="true" termPositions="true" termOffsets="true"
If the term vectors are not found it falls back to UnifiedSolrHighlighter
Put position-highlighter-1.0.jar in a folder and add the following to solrconfig.xml
<lib path="<path to jar>/position-highlighter-1.0.jar" />
modify highlight searchComponent and add class="org.apache.solr.highlight.PositionsSolrHighlighter"
<searchComponent class="solr.HighlightComponent" name="highlight">
<highlighting class="org.apache.solr.highlight.PositionsSolrHighlighter">
<!-- Configure the standard fragmenter -->
<!-- This could most likely be commented out in the "default" case -->
<fragmenter name="gap"
default="true"
class="solr.highlight.GapFragmenter">
<lst name="defaults">
<int name="hl.fragsize">100</int>
</lst>
</fragmenter>
Parameters:
-
hl.pos
-
true: return only positions and tokens
-
*false: return snippets with positions (default)
-
-
hl.fragsize default to 100 to control the length of the snippets (0 for all text)
-
hl.offsets
-
true: also return token offset start and end
-
*false: default return only position
-