Thursday, April 28, 2022

Solr Computed Index Field & Rebuild Index using Sitecore CLI

                                    


In this blog, we can look into Sitecore search with the Solr computed index field. A computed index field is processed for every Sitecore item that gets indexed. 

Use case:


            Consider an example of a food product that has different search criteria based on category, ingredients and allergy content, etc,. 



How can do it simpler using Sitecore-Solr?  

Computed Index Field


Sitecore Items


               I have attached the template structure of the Product and search criteria from Sitecore.

Template Structure

          

Item Structure

                  This is how the items look like with the search criteria


SOLR Index Field

                Our Computed Index field should look like this as highlighted below






How do achieve it? 


Solr Configuration

          Create the Solr computed Index field as below with the appropriate return type in my case it is string collection.
 

Computed Index Field

           Combining those field values into a single computed field.


API Output

                 My simple API look like :)

URL: https://samplecm.dev.local/api/sitecore/productbycategory/GetProducts?queryText=gluten

 


URL: https://samplecm.dev.local/api/sitecore/productbycategory/GetProducts?queryText=wheat

                              
                                        


 Complete Code Repo available here =>

https://github.com/SriramGayathri/SitecoreComputedIndexFieldExample

Tips:

    If the computed index field does not appear in SOLR, we have got a cool feature in Sitecore CLI - Index Manager

  • Populate solr schema
  • Rebuild Index  



More details on the Sitecore CLI commands can be found on the Sitecore docs =>


                                            Happy Sitecore Learning!!!

No comments:

Post a Comment