Search code examples
configurationsolrcode-snippetshighlight

where to put highlighting snippet configration in solr 3.4


I'm a beginner in solr, I need to add the highlight configuration (color, snippet, ....) in solrConfig.xml. which tag shall I use?? can anyone give an example ??.

thanks


Solution

  • You can specify the highlight parameters in request url as well as solrconfig.xml

    The solrconfig.xml file available as a part of the packaged solr example adds in the highlighting settings.

    e.g. -

    <requestHandler name="/browse" class="solr.SearchHandler">
        <lst name="defaults">
          <str name="echoParams">explicit</str>
          .....
    
          <!-- Highlighting defaults -->
          <str name="hl">on</str>
          <str name="hl.fl">text features name</str>
          <str name="f.name.hl.fragsize">0</str>
          <str name="f.name.hl.alternateField">name</str>
    
          ...
        </lst>
    
     </requestHandler>
    

    The highlight component can be configured for the fields needed to be highlighted on, the snippets size, count, snippets formatter and much more.

    By default the items are highlight using the <em></em> tags.

    For colored highlight you would need to use the colored fragmentsBuilder and fast vector highlighter.

    <str name="hl">on</str>
    <str name="hl.fl">text features name</str>
    <str name="hl.useFastVectorHighlighter">true</str>
    <str name="hl.fragmentsBuilder">colored</str>
    

    Also, for FastVectorHighlighter requires the field is termVectors=on, termPositions=on and termOffsets=on

       <field name="text" type="text_general" indexed="true" stored="false" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
    

    Detailed list of parameters @ http://wiki.apache.org/solr/HighlightingParameters