SOLR - highlight searching text ? Is this possible

724 views Asked by At

I'm beginning with SOLR so please don't flame me if this question is stupid or something like this. I was reading solr documentation and found out that there is something called "highlight". I have really simple query:

/select?q=text:test&wt=json&indent=true

text is a field in my index and I'm trying to highlight all results this query highlight only first hit:

/select?q=text:text&wt=json&indent=true&hl=true&hl.simple.pre=<b>&hl.simple.post=</b>

Whan I'm doing wrong ? Is there any possibility for example to cut 50 chars more after hightlight and get not only first hit highlighted

1

There are 1 answers

0
tkja On BEST ANSWER

There is a Solr wiki entry on HighlightingParameters that you should read to get familiar with Solr and Highlighting at: https://wiki.apache.org/solr/HighlightingParameters

Specifically, what you should consider is hl.snippets and hl.fragsize.

To quote the important part from the wiki:

hl.snippets

The maximum number of highlighted snippets to generate per field.

-

hl.fragsize

The size, in characters, of the snippets (aka fragments) created by the highlighter.

To quickly test it out and get started, add the parameters with some high value to your Solr query, for instance:

&hl.fragsize=5000&hl.snippets=5000