Monday, 15 May 2017

Not getting html tags in rich text editor field using solr in Sitecore

I have faced some issue when i am fetching html tags from rich text editor field in sitecore using solr.
Rich text editor fields only returns plain text.

Solution:

Please perform below steps in config file

1. open the 'Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config' file and change the following line from
<fieldReader fieldTypeName="HTML|rich text" fieldReaderType="Sitecore.ContentSearch.FieldReaders.RichTextFieldReader, Sitecore.ContentSearch" />
to
<fieldReader fieldTypeName="html|rich text" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" />

2. Rebuild search indexes

=======================================================================

Now I have two or three fields content Rich text editor and I have getting only one field value with HTML text and others fields value with plain text,

please use following approach

1. Open the 'Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config' file and revert our previous change by replacing the following line
<fieldReader fieldTypeName="HTML|rich text" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" />
with
<fieldReader fieldTypeName="HTML|rich text" fieldReaderType="Sitecore.ContentSearch.FieldReaders.RichTextFieldReader, Sitecore.ContentSearch" />

2. For all fields that should be indexed "as is" without stripping HTML tags add the following lines inside <fieldReaders> XML node:
<mapFieldByFieldName hint="raw:AddFieldReaderByFieldName">
  <fieldReader fieldName="<field1>" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" />
  <fieldReader fieldName="<field2>" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" />
</mapFieldByFieldName>

where <field1>, <field2> - are names of the fields that should be saved "as is"

3. Rebuild the search indexes

Might be this helpful to you for fetching data from rich text editor using solr in sitecore.

No comments:

Post a Comment