Add Custom Fields in SOLR Index on Crawler

While upgrading the project from Sitecore version 8.2 to 10.2 I faced one scenario to convert the Lucene Search configuration to the SOLR.

It’s easier to convert the Lucence configuration to the SOLR if all configurations are defined in the configuration files. You just need to change the type to the Solr Provider and configuration to the defaultSolrIndexConfiguration or if it does not default then define the custom Solr Index configuration.

The problem occurs when the index file is generated at runtime and custom fields are added dynamically either on the pipeline or Search Crawler. In my case in Sitecore 8.2 lucence configuration fields were added in the document at runtime on SitecoreItemCrawler.

Custom Crawler:

Code was written on the custom crawler:

Solution:

To resolve the above issue and find the solution, I have explored Sitecore.ContentSearch DLL and found out it provides the below method in the IProviderUpdateContext interface.

In Sitecore 10.2 it takes a parameter object as a type of Dictionary. Hence I updated the code as mentioned below:

After building and publishing the code it's working perfectly fine and I get the result into the SOLR query.

azure-cdn-sitecore

Happy Sitecoreing ðŸ˜Š

Comments

Popular posts from this blog

Sitecore Installation Error: Failed to Start Service 'Sitecore Marketing Automation Engine'

Import CSV Data in Sitecore Using PowerShell: Part-3

Sitecore Technology MVP Journey 2022