Solr highlighting

2019-05-15 23:54发布

问题:

I saw this post here, he explains well howto show a highlighted result, but for me this is not going to work...

I am getting the lst with highlighting and all, but the text in that is very less compared to the original response without highlighting...

How do I merge highlighting content with original result set in php ?

回答1:

Try hl.fragsize to increase the size of the highlighted snippet returned by Solr.



回答2:

I would recommend to use a non-default highlighter to get much better results. Search in you solrconfig.xml for your RequestHandler:

<requestHandler name="/select" class="solr.SearchHandler">

and add the following:

<str name="hl.usePhraseHighlighter">false</str>
<str name="hl.useFastVectorHighlighter">true</str>
<str name="hl.boundaryScanner">breakIterator</str>

Now goto the Highlighter section

<searchComponent class="solr.HighlightComponent" name="highlight">

and search for this line:

<boundaryScanner name="default" default="false" class="solr.highlight.SimpleBoundaryScanner">

Make sure you set it to "default=false". Afterwards configure the BoundaryScanner defined above as default:

<boundaryScanner name="breakIterator" default="true" class="solr.highlight.BreakIteratorBoundaryScanner">

For this scanner change the type to "SENTENCE":

<str name="hl.bs.type">SENTENCE</str>

And set your language and country setting.

This change gave me a lot better hightlighting results!

Awww - almost forgot to mention the changes in schema.xml. Get the fiel you want to highlight and add following options:

termVectors="true" termPositions="true" termOffsets="true"