Term highlighting

By default, Solr highlights searched terms in the summary content as described in the following snippet:

<cfsearch 
collection="syn1" 
criteria="Services solr" 
name="results" 
status="r" 
suggestions="always" 
contextPassages="1">

To highlight contents in the entire document, modify the solrconfig.xml and schema.xml files. These files are available in the following locations:

  • <Collection Directory>/conf: Modify files in this location to apply the changes to all future Solr collections.

  • <Solr Home>/multicore/template/conf: Modify files in this location to apply the changes only to a particular collection.

  1. Stop Solr service.

  2. Replace the following section in the solrconfig.xml

    <requestHandler name="standard" class="solr.StandardRequestHandler" default="true"> 
        <!-- default values for query parameters --> 
         <lst name="defaults"> 
           <str name="echoParams">explicit</str> 
           <str name="hl.fl">summary title </str>  
           <!-- omp = Only More Popular --> 
           <str name="spellcheck.onlyMorePopular">false</str> 
           <!-- exr = Extended Results --> 
           <str name="spellcheck.extendedResults">false</str> 
           <!--  The number of suggestions to return --> 
           <str name="spellcheck.count">1</str> 
           
         </lst> 
         <arr name="last-components"> 
          <str>spellcheck</str> 
         </arr> 
      </requestHandler>

    with

    <requestHandler name="standard" class="solr.StandardRequestHandler" default="true"> 
        <!-- default values for query parameters --> 
         <lst name="defaults"> 
           <str name="echoParams">explicit</str>  
           <str name="hl.fl">contents title </str>  
           <!-- omp = Only More Popular --> 
           <str name="spellcheck.onlyMorePopular">false</str> 
           <!-- exr = Extended Results --> 
           <str name="spellcheck.extendedResults">false</str> 
           <!--  The number of suggestions to return --> 
           <str name="spellcheck.count">1</str> 
           
         </lst> 
         <arr name="last-components"> 
          <str>spellcheck</str> 
         </arr> 
      </requestHandler>
  3. Replace the following section in the schema.xml

    <field name="contents" type="text" indexed="true"  stored="false" required="false" multiValued="true" omitNorms="true"/>

    with

    <field name="contents" type="text" indexed="true" stored="true" required="false" multiValued="true" omitNorms="true"/>
  4. Restart Solr.

  5. Reindex the collection.

Note: The modifications to solrconfig.xml and schema.xml will increase the index size.