Sitecore Content Search Latest Version / Sitecore 10 Solr Version

Sitecore Content Search Latest Version / Sitecore 10 Solr Version

Published on : November 14, 2022

Sitecore Content Search Latest Version / Sitecore 10 Solr Version

Support for the Lucene search engine is no longer included in Sitecore 9.3 and later. We can use either the Solr search engine or Azure search. Solr is installed and configured by default in a Sitecore installation.

What’s new in Sitecore 10.1 Solr?

 We can configure Solr to retry an operation if the first attempt to run the operation fails. This is useful if you experience transient errors, such as network problems, or you have Solr availability issues.
 We can configure the strategy to use in the solrRetryer section of the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config

Different types of Solr Retryer available:

1. NoRetryRetryer: This is the default strategy where retry is never done on failure. We can configure it like this:
<solrRetryer type=”Sitecore.ContentSearch.SolrProvider.Availability.Retryer.NoRetryRetryer, Sitecore.ContentSearch.SolrProvider” singleInstance=”true” />

2. FixedIntervalsRetryer: This strategy retries in fixed intervals that we specify.
<solrRetryer type=”Sitecore.ContentSearch.SolrProvider.Availability.Retryer.FixedIntervalsRetryer, Sitecore.ContentSearch.SolrProvider” singleInstance=”true” >
<sleepDurations hint=”list:AddSleepDuration”>
<interval>00:00:01</interval>
<interval>00:00:02</interval>
<interval>00:00:03</interval>
</sleepDurations>
</solrRetryer>

3. ExponentialRetryer: It is based on exponential backoff algorithm.
<solrRetryer type=”Sitecore.ContentSearch.SolrProvider.Availability.Retryer.ExponentialRetryer, Sitecore.ContentSearch.SolrProvider” singleInstance=”true”>
<param desc=”retryCount”>3</param>
<param desc=”deltaBackoff”>00:00:01</param>
<param desc=”maxBackoff”>00:00:05</param>
<param desc=”minBackoff”>00:00:01</param>
</solrRetryer>

Custom Retryer:

In addition to default retryer strategies we can create a custom retryer strategy by following the steps given below:
1. Create a class that inherits the Sitecore.ContentSearch.SolrProvider.Availability.Retryer.BaseRetryer class.
2. Implement the methods you need.
3. Enable the custom retryer in the solrRetryer section of the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file.

Find out if the Solr search service is available

If the Solr search service is not available when you run a query, the search provider produces a result similar to the result you get when you run a LINQ query against an empty collection. This topic shows how you can decide if the empty result occurs because the search service is not available.

By running the following query an array with atleast one element is returned.

var result = context.GetQueryable<SearchResultItem>()
.Where(it => it.Content == ” sitecore”).ToArray();
For the above query, an empty array is returned if the Solr service is not available. We can also use other LINQ methods such as .First()
var result = context.GetQueryable<SearchResultItem>()
.Where(it => it.Content == “sitecore”).First();

The first element that matches the search query is returned as output if Solr service is available. Incase of unavailability of Solr service, InvalidOperationException (“Sequence contains no elements.”) exception is thrown.

To distinguish between whether the search query returns an empty result or is it because of search service not available, we can pass an instance of the ThrowOnErrorExecutionContext to the following query:

var result = context.GetQueryable<SearchResultItem>(new ThrowOnErrorExecutionContext())
.Where(it => it.Content == “sitecore”).ToArray();

When we apply ThrowOnErrorExecutionContext context to the query, the LINQ query returns the same result as under the previous conditions. To catch the SearchServiceUnavailableException exception that occurs if the Solr instance is not available, then we can make use of the catch block and handle the same.

var queryable = context.GetQueryable<SearchResultItem>(new ThrowOnErrorExecutionContext());
try
{
var result = queryable.Where(it => it.Content == “sitecore”).ToArray();
}
catch (SearchServiceUnavailableException ex)
{
// Handle unavailable search service
}

Sitecore Content Search Latest Version / Sitecore 10 Solr Version

Author: Dhanush, Sitecore Specialist

Scroll to Top