1
votes

Am I missing something with highlighting in Solr? I cant get it to work in my Solr xml results page.

http://localhost:8080/solr/select?q=book&hl=true

Above is a basic query for the term book which I would like highlighted in my results.

I also have the default set in my solrconfig:

<searchComponent class="solr.HighlightComponent" name="highlight">
    <highlighting>
      <!-- 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>

Is there something I need to set in my 'content' field in the schema? Thank you in advance.

1

1 Answers

4
votes

You need to also set the field(s) that you want highlighting results returned for:

http://localhost:8080/solr/select?q=book&hl=true&hl.fl=content

You can probably set this in the section of your as well.

Edit: You also need to enable the highlight component in your <requestHandler name="/select" class="solr.SearchHandler"> in your solrconfig.xml file. Assuming that you are using the standard /select request handler. To do that, you need to uncomment and modify the <arr name="components"> section at the bottom of that <requestHandler> section to look like the following:

 <arr name="components">
   <str>highlight</str>
 </arr>

That should enable the highlighting component in your searches.