Menu

Solr search Rich text field

Sitecore Solr stripping out the HTML from Rich Text Field while indexing Issue Resolved

I migrated Sitecore 8 to Sitecore 10.3, but it affected my search results content coming from a rich text field name description. Content written in Sitecore rich text field with some html / css styles were missing.

Sitecore Rich Text field not indexing Investigation

I checked the Solr dashboard of master and web indexing, but there as well data of each Rich Text field were just plain text. Later a lit bit of research, found Sitecore 10.3 content search default Solr index configuration missing MapFieldbyFieldName node configurations.

I found I had this configuration in Sitecore 8, so compared the configurations and added MapFieldbyFieldName node with Rich Text Field description.

Solution for Rich Text Editor field only returns plain text

To resolve this issue you we can have two approaches

  1. Updating the Solr default index configurations

In Sitecore 10.3 navigate to the path: App_Config\Sitecore\ContentSearch, then update the file name: Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config with the below configuration.

In FieldReaderType node of Sitecore fieldtype map section

			<mapFieldByFieldName hint="raw:AddFieldReaderByFieldName">
			<fieldReader fieldName="Description" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" />
			</mapFieldByFieldName>	

Or

2. Adding separate patch with fieldreaders with mapfieldbyfieldname node in App_config/Include.

We can add a patch name descrptionrichtexfieldindexing.config as below

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <indexConfigurations>
        <defaultSolrIndexConfiguration>
           <fieldReaders>
            <mapFieldByFieldName hint="raw:AddFieldReaderByFieldName">
                <fieldReader fieldName="description" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" />
            </mapFieldByFieldName>           
          </fieldReaders>
        </defaultSolrIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

Next steps:

a) Rebuild your all indexes

b) Validate the patch applied correctly using Sitecore/admin/showconfig.aspx

c). Checking Solr query results in Solr dashboard by selecting any core and query the Rich Text field results.

You will find Rich Text field returning the html in Solr search query in Solr dashboard or in your Sitecore Solr page search.