SearchStax Help Center

The SearchStax Help Center Frequently Asked Questions page includes FAQs about SearchStax Managed Search, our hosted Apache Solr Cloud service.


POST vs. GET Requests

Overview

SearchStax Managed Search service Solr queries may be submitted using either the GET or POST HTTP method. The query string of a GET request is included as part of the URL in the request header. In a POST request, the query string is part of the data payload and does not inflate the header size.

Some applications, notably Sitecore, generate very large query strings that can exceed the maximum HTTP header size of a GET request, resulting in HTTP 413 errors.

If your queries run out of header space, you’ll be interested in these possible strategies:

  • Adjust HTTP header size. The header size can be increased as needed on Azure single-node deployments; but only up to a limit of 32 KB on Azure clusters. This means that large header sizes on test (single-node) deployments often cannot be transferred to production clusters on Azure.
  • Use POST queries instead of GET queries. This moves the query string out of the HTTP header into the body of the request.
    • For Sitecore 9.0 only, there is a special Sitecore configuration setting that forces all queries into POST format. Other versions of Sitecore don’t have this setting. (See example below.)
    • For custom web apps, you can submit all queries using the POST method. (See examples below.)
  • Adjust the query complexity to reduce the size of the query string. See Solr query error – URI Too Long for suggestions on how to pare down the Sitecore queries to meet this limitation. Ultimately, you’ll need to discuss this with Sitecore support.

Using POST Queries

Sitecore 9.0

In Sitecore 9.0 only, there is a configuration setting to force all Sitecore queries to use the POST method instead of the GET method. This sidesteps the problem of filling up the HTTP header.

The setting is in the \App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file.

           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" />

To be best of our knowledge, this feature appears in Sitecore 9.0 only.

POST Queries using Curl and PowerShell

If you encounter this 413 heading error in a non-Sitecore context, you can issue POST query requests using the following Linux curl or Windows PowerShell request formats.

Linux:

curl -d "q=*:*&rows=1" https://ss123456-dkwl9slx-ca-central-1-aws.searchstax.com/solr/filmcollection/select

Note that the -d (data) switch automatically casts the request as a POST message.

PowerShell:

$params= @{
     q='*:*'
     rows=10
     wt='json'
     indent='true'
     fl='id,movie_title,title_year'
          }

$queryresults = Invoke-RestMethod -Method Post -body $params `
                -ContentType 'application/x-www-form-urlencoded' `
                -uri "https://ss123456-dkwl9slx-ca-central-1-aws.searchstax.com/solr/filmcollection/select"

Questions?

Do not hesitate to contact the SearchStax Support Desk.


Return to Frequently Asked Questions.