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.
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
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
Happy Sitecore Learning!!!