Question

I have seen documents on solr highlighting and i found that i need to change the default value of snippet. I have given value at 20 and made the maxAnalyzedChars 999999 from schema.xml. even then i get only the first occurance.

I have also added some part in solrconfig.xml also

<requentestHandler name="/search"  class="solr.SearchHandler"> 
<lst name="defaults"> 
 <str name="defType">dismax</str> 
 <int name="rows">10</int> 
 <str name="echoParams">explicit</str> 
 <str name="qf">content&#94;0.5 title&#94;1.2 </str> 
 <str name="q.alt">*:*</str> 
 <bool name="hl">true</bool> 
 <str name="hl.fl">title content url</str> 
 <str name="f.content.hl.fragsize">20</str> 
 <str name="f.content.hl.snippets">3</str>  
 <str name="f.content.hl.alternateField">content</str> 
 <str name="f.title.hl.fragsize">0</str> 
 <str name="f.title.hl.alternateField">title</str> 
 <str name="f.url.hl.fragsize">0</str> 
 <str name="f.url.hl.alternateField">url</str> 
</lst> 

Can anyone pls help me out? I am new to Solr. My requirment is to fetch the phrases containing a given word.

Was it helpful?

Solution 2

I tried Solr Highlighting to find the multiple occurrences of searched text. Solr gives only one occurrence by default. I tried with /select request handler. While querying I passed the following parameters.

hl.fragsize=999999999&hl.maxAnalyzedChars=999999999

Now, it's able to find the multiple occurrences of the searched text. I hope these parameters will also work for your /search handler. So, try to provide a very large number for hl.fragsize and hl.maxAnalyzedChars.

OTHER TIPS

Just use the hl.snippets param to specify the number of snippets you want.

[Edit] - Regarding your comments, it seems that you were querying the wrong requestHandler. Well, that might explain your problem, then. Anyway, here are some clarifications that might be useful :

  • hl.snippets corresponds to the maximum number of snippets to be returned. Use it as a limit.

  • hl.fragsize corresponds to the length of the string you want to be returned from the matched field (snippets length). A value of "0" means unlimited length or whole field.

When hl.fragsize is set to a value greater than a field's content length, the highlighter can return only one single snippet from that field (the entire field), regardless of hl.snippets value or the number of match in that field.

To obtain the phrase that contains highlighting as a snippet, use a fragsize equivalent to what you consider as an average phrase length (100~300 are commonly used values).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top