Adapt your search settings to Solr availability
Sitecore includes mechanisms for monitoring the availability of Solr search, and responding to any Solr downtime in a resilient way. You can use these mechanisms, and a Solr endpoint, to adapt your implementation to the availability of Solr search. If you're using Solr 8 or later, Sitecore can use IsSolrAliveAgent to periodically check the availability and health of the Solr service, and IndexingStateSwitcher to manage Solr content search indexing and search behavior. The agents automatically restore Sitecore search and indexing functionality when the Solr server becomes available, meaning Sitecore administrators don't have to do anything. IsSolrAliveAgent and IndexingStateSwitcher are both enabled by default. This article explains their usage and how to change their default timeout values if needed.
Additionally, you can use the /solr/healthz/ready endpoint provided by Solr to monitor the health and readiness of the Solr server, and to restart the Solr service if needed. You can also check if the Solr search service is available whenever you run a query.
Solr search is only for internal use in SitecoreAI's UI, and should not be modified. For creating search features, use search tools such as Sitecore Search. For more information on integrating Sitecore Search in your SitecoreAI environment, see Integrating Sitecore Search.
IsSolrAliveAgent
IsSolrAliveAgent checks if the Solr service is running and responsive. The agent makes HTTP requests to Solr endpoints such as /solr/{core_name}/admin/healthcheck or /solr/admin/info/system. If Solr doesn't send a timely response, or if it returns an error message, it's considered either Unreachable or Not responding. The agent then logs a warning message in the Sitecore log. It's important to differentiate between the two states:
-
Unreachable - an issue is preventing communication with the Solr server, such as network problems or firewall restrictions.
-
Not responding - the server received the request but failed to provide a timely or successful response, possibly due to server overload or configuration errors.
If the Solr server is unreachable, it returns an error message to Sitecore. However, if it doesn't respond at all during a defined timeout duration, it is considered unresponsive (Not responding). You can adjust the timeout value to differentiate between these scenarios, as described later in this topic.
IndexingStateSwitcher
IndexingStateSwitcher controls indexing and search behavior based on the availability of the Solr service. It ensures that indexing operations are synchronized with Solr availability to maintain data integrity. When Solr is detected as unavailable, this agent can pause indexing operations to prevent potential data inconsistencies or errors. It also helps prevent overloading Solr with indexing requests during downtime. When Solr becomes available again, the IndexingStateSwitcher agent automatically resumes indexing operations.
You can configure the timeout value for IndexingStateSwitcher, as described in the following section.
Configure the timeout value of an agent
The timeout values for IsSolrAliveAgent and IndexingStateSwitcher are both defined in seconds, using the interval attribute. You change the timeout setting by patching the configuration in the App_Config\Include folder. You can also specify the Solr connection timeout.
To configure the timeout value of the IsSolrAliveAgent or the IndexingStateSwitcher agent using a patch file:
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
-
Create a
.configfile in theApp_Config\Includefolder, for example,Sitecore.ContentSearch.Solr.config.
-
In the config file, enter the following code structure, and change the
intervalfor the agent as needed. In the following example, the intervals are set to 15 and 3 seconds, respectively.RequestResponse<?xml version="1.0" encoding="utf-8" ?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/"> <sitecore role:require="Standalone or ContentManagement or ContentDelivery or XMCloud" search:require="solr"> <scheduling> <agent type="Sitecore.ContentSearch.SolrProvider.Agents.IsSolrAliveAgent, Sitecore.ContentSearch.SolrProvider" method="Run" interval="00:15:00" /> <agent type="Sitecore.ContentSearch.SolrProvider.Agents.IndexingStateSwitcher, Sitecore.ContentSearch.SolrProvider" method="Run" interval="00:03:00" /> </scheduling> </sitecore> </configuration> -
Restart the Sitecore application.
-
After you save your file, you can check to see the change reflected in
https://{sitecore_instance_name}/sitecore/admin/showconfig.aspx, replacing{sitecore_instance_name}with your instance.