CloudSolrClient URL Too Long

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

CloudSolrClient URL Too Long

Joe Obernberger
Hi - I'm using SolrCloud 7.3.1 and calling a search from Java using:

org.apache.solr.client.solrj.response.QueryResponse response =
CloudSolrClient.query(ModifiableSolrParams)

If the ModifiableSolrParams are long, I get an error:
<h1>Bad Message 414</h1><pre>reason: URI Too Long</pre>

I have the maximum number of terms set to 1024 (default), and I'm using
about 500 terms.  Is there a way around this?  The total query length is
10,131 bytes.

Thank you!

-Joe

Reply | Threaded
Open this post in threaded view
|

Re: CloudSolrClient URL Too Long

Alexandre Rafalovitch
Have you tried using POST, instead of GET:
https://lucene.apache.org/solr/7_3_0//solr-solrj/org/apache/solr/client/solrj/SolrClient.html#query-java.lang.String-org.apache.solr.common.params.SolrParams-org.apache.solr.client.solrj.SolrRequest.METHOD-

Also, if you have a set of parameters that do not change between
calls, you can have them as defaults (or compulsory) values in
solrconfig.xml for a custom QueryHandler definition. This includes
variable substitutions.

Regards,
   Alex.

On 12 July 2018 at 14:48, Joe Obernberger <[hidden email]> wrote:

> Hi - I'm using SolrCloud 7.3.1 and calling a search from Java using:
>
> org.apache.solr.client.solrj.response.QueryResponse response =
> CloudSolrClient.query(ModifiableSolrParams)
>
> If the ModifiableSolrParams are long, I get an error:
> <h1>Bad Message 414</h1><pre>reason: URI Too Long</pre>
>
> I have the maximum number of terms set to 1024 (default), and I'm using
> about 500 terms.  Is there a way around this?  The total query length is
> 10,131 bytes.
>
> Thank you!
>
> -Joe
>
Reply | Threaded
Open this post in threaded view
|

Re: CloudSolrClient URL Too Long

Shawn Heisey-2
In reply to this post by Joe Obernberger
On 7/12/2018 12:48 PM, Joe Obernberger wrote:

> Hi - I'm using SolrCloud 7.3.1 and calling a search from Java using:
>
> org.apache.solr.client.solrj.response.QueryResponse response =
> CloudSolrClient.query(ModifiableSolrParams)
>
> If the ModifiableSolrParams are long, I get an error:
> <h1>Bad Message 414</h1><pre>reason: URI Too Long</pre>
>
> I have the maximum number of terms set to 1024 (default), and I'm
> using about 500 terms.  Is there a way around this?  The total query
> length is 10,131 bytes.

Add a parameter to the query call.  Change this:

client.query(query)

to this:

client.query(query, METHOD.POST)

The import you'll need for that is
org.apache.solr.client.solrj.SolrRequest.METHOD.

What you're running into is the length limit on the HTTP request of 8192
characters.  This is the limit that virtually all webservers, including
the Jetty that Solr includes, have configured.  Changing the request
method to POST puts all those parameters into the request body.  Solr's
default limit on the size of the request body is 2 megabytes.

Thanks,
Shawn

Reply | Threaded
Open this post in threaded view
|

Re: CloudSolrClient URL Too Long

Joe Obernberger
Shawn - thank you!  That works great.  Stupid huge searches here I come!

-Joe


On 7/12/2018 4:46 PM, Shawn Heisey wrote:

> On 7/12/2018 12:48 PM, Joe Obernberger wrote:
>> Hi - I'm using SolrCloud 7.3.1 and calling a search from Java using:
>>
>> org.apache.solr.client.solrj.response.QueryResponse response =
>> CloudSolrClient.query(ModifiableSolrParams)
>>
>> If the ModifiableSolrParams are long, I get an error:
>> <h1>Bad Message 414</h1><pre>reason: URI Too Long</pre>
>>
>> I have the maximum number of terms set to 1024 (default), and I'm
>> using about 500 terms.  Is there a way around this?  The total query
>> length is 10,131 bytes.
> Add a parameter to the query call.  Change this:
>
> client.query(query)
>
> to this:
>
> client.query(query, METHOD.POST)
>
> The import you'll need for that is
> org.apache.solr.client.solrj.SolrRequest.METHOD.
>
> What you're running into is the length limit on the HTTP request of 8192
> characters.  This is the limit that virtually all webservers, including
> the Jetty that Solr includes, have configured.  Changing the request
> method to POST puts all those parameters into the request body.  Solr's
> default limit on the size of the request body is 2 megabytes.
>
> Thanks,
> Shawn
>
>
> ---
> This email has been checked for viruses by AVG.
> https://www.avg.com
>