We're currently working on a Sitecore 10.4 solution hosted in a Docker-based containerized environment, with Solr search integrated as part of the architecture.
While implementing custom Solr indexes, we encountered an issue in the live environment where the search functionality became unresponsive during index rebuilding. The results only started appearing again once the indexing process was complete.
To address this, I explored a few community resources and came across two helpful articles that outlined the same approach for setting up custom Solr indexes in Docker. Seeing consistency in both guides gave me the confidence to adopt the same approach for our setup. 😊
https://sitecoreblog.frankbatallas.com/2023/03/30/create-a-custom-index-in-sitecore-with-docker/
As outlined in the blogs mentioned above, I made the following changes in the solr-init
configuration to create custom indexes during initialization.
#Created a new JSON file specifying the names of our custom indexes
{
"sitecore": [
"_my_custom_master_index",
"_my_custom_web_index",
"_my_custom_web_index_rebuild"
] }
#Also added a configuration file for the indexes, structured as follows:
Everything was working smoothly up to this point. I was able to load the custom indexes successfully in the Sitecore Index Manager, and the index build process worked flawlessly for all the targeted templates and fields.
We then deployed these changes to the live environment, and everything appeared to be functioning well—until we attempted to trigger indexing for certain Sitecore content items. That’s when we noticed an issue: the Sitecore search results page became unresponsive, displaying the message No Results Found. (This is our default message shown when Solr returns no search results.)
We were initially unable to determine the cause of this behavior and after lot of troubleshooting we reached out to Sirecore Support with our problem. With their help, we identified the right solution using Switch Indexes on rebuild
And, these below are some steps that Sitecore suggested in CustomSolrJson:
Change for CustomSolrConfig
#Update config change to
Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrCloudSearchIndex
#And add mainAlias and rebuildCollection as mentioned in below screenshot
#Rebuilt the sitecore_my_custom_web_index index.
Above mentioned steps in sitecore documentation and sitecore support guidance helped us to fix the issue on prod as
SwitchOnRebuildSolrCloudSearchIndex
class leverages Solr collection aliases. It uses the active alias for search and update operations, and the rebuild alias during index rebuilds. Once the rebuild is complete, the CREATEALIAS
command is used to swap the collections referenced by the aliases.
No comments:
Post a Comment