ArgumentNullException is thrown if Azure Search query matches more than 1000 documents


Description

The Azure Search engine has a feature called Continuation of Partial Search Responses. This feature allows you to read all the documents that match a query even if the number of matching documents exceeds the limit (1000 documents). The Azure Search provider adds an extra slash ("/") to the URL of the continuation requests. Due to this, the Azure Search service might return a 404 Not Found status code, resulting in an error and empty search results. The following message can be found in the logs:

Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: s
Source: mscorlib
   at System.IO.StringReader..ctor(String s)
   at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
   at Sitecore.ContentSearch.Azure.Http.SearchResultsDeserializer.Deserialize(String textResults)
   at Sitecore.ContentSearch.Azure.Query.SearchResultIterator.LoadNextPage(SearchRequest& nextPageRequest)
   at Sitecore.ContentSearch.Azure.Query.SearchResultIterator.MoveNext()
   at Sitecore.ContentSearch.Azure.Query.SearchResultIterator.<GetEnumerator>d__9.MoveNext()
   at Sitecore.ContentSearch.Azure.Query.CloudSearchResults`1.<GetSearchHits>d__15.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()

Solution

To resolve the issue:

For Sitecore XP 9.3, download and install the corresponding cumulative hotfix available in KB1001868.

Alternatively, switch to the Solr search provider.