We were querying Solr to get results based on certain taxonomies subscribed by the user. It was working fine but for certain users Solr was not returning any result. It was strange because those taxonomies had documents indexed in Solr. To troubleshoot further, I checked logs and found below error –

29180 07:38:56 ERROR Error during executing a query.
Exception: SolrNet.Exceptions.SolrConnectionException
Message: <h1>Bad Message 414</h1><pre>reason: URI Too Long</pre>
Source: SolrNet
   at SolrNet.Impl.SolrConnection.Get(String relativeUrl, IEnumerable`1 parameters)
   at SolrNet.Impl.SolrQueryExecuter`1.Execute(ISolrQuery q, QueryOptions options)
   at Sitecore.ContentSearch.SolrProvider.LinqToSolrIndex`1.ExecuteQuery(SolrCompositeQuery compositeQuery, QueryOptions options)

Nested Exception

Exception: System.Net.WebException
Message: The remote server returned an error: (414) URI Too Long.
Source: System
   at System.Net.HttpWebRequest.GetResponse()
   at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse()
   at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request)
   at SolrNet.Impl.SolrConnection.Get(String relativeUrl, IEnumerable`1 parameters)

Root Cause – Query to Solr was too long so it was getting rejected by Solr.

Solution – We need to increase the size or length of query accepted by Solr. These are the solutions based on your Sitecore instance –
1.  If Solr is installed separately then there is a property in Solr to change the requestHeaderSize attribute value to a higher value. You can find it under your Solr instance in jetty.xml file.          The path of this is file is below.
    File – [solr]/server/etc/jetty.xml
    Setting this value will allow Solr to support larger sizes for GET requests. It should look like this.
<Set name="requestHeaderSize"><Property name="solr.jetty.request.header.size" default="8192" /></Set>
2. If using Solr as docker container service, then add following environment variable to Solr service part of docker-compose file.
  - SOLR_OPTS=-Dsolr.jetty.request.header.size=65535

3. Sitecore has provided setting ContentSearch.Solr.SendPostRequests  to change request from GET to POST. It is very quick and easy fix.
  <setting name=”ContentSearch.Solr.SendPostRequests” value=”true”/>

Thanks for reading.

 

Leave a Comment

Your email address will not be published. Required fields are marked *