0

My query from Sitecore to Solr is too long and its giving error URI too Long in the logs. Is there any setting on Sitecore or Solr side that can allow any query of any length ?

I am using Sitecore 10 update 1 as docker container services.

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)
3

2 Answers 2

1

There are a few ways to handle this issue:

  1. Increase the maximum URI length limit on your web server. This can be done by modifying the web.config or server settings.
  2. Optimize your Solr query by reducing the number of parameters or using more efficient filtering options. Consider using facets, sorting, and paging to narrow down the search results.
  3. Break the query into smaller chunks and make multiple requests to Solr. This can be achieved by using pagination or splitting the query into multiple requests. Upgrade to a newer version of Solr that supports larger URI lengths. Solr 8.2 and later versions support URIs up to 8KB in length.

As potential solution, I would like to recommend to switch to SOLR POST requests. POST requests allow for larger payloads than GET requests, so the query string size limitation would not be a problem. On my opinion, that's the best solution of this issue.

In Sitecore, you can change the default query method to POST by updating the setting in the \App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file.

The config setting name will sounds like (this config is used for Sitecore 9)

           This setting specified whether POST method is always used to communicate with SOLR. If value is false, GET can be used for some Solr commands.
           The setting can be useful if you face issues related to URI length limitation.  
           Default value: false
      -->
      <setting name="ContentSearch.Solr.SendPostRequests" value="false" />

I am trying to find out a fresh documentation for configuring SOLR POST request for Sitecore 10 but haven't found it yet.

0

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.

[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>

Try updating this value and see if it solves your issue.

Refer to this article for more details.

https://www.symsoftsolutions.com/sitecore/solr-post-request-not-working-in-sitecore-9-1/

If you are using Docker, you can update the YML file with this

SOLR_OPTS=-Dsolr.jetty.request.header.size=65535

Refer to this thread to change this value in docker.

How to change solr.jetty.request.header.size in docker

2
  • I am using Solr as docker container service, I could not find any file with name - jetty.xml
    – Siddharth
    Mar 9, 2023 at 13:34
  • @Siddharth Updated my answer. Mar 9, 2023 at 13:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.