The correct way to add a custom query parameter to Solr

I am currently running a Solr client / server pair that is working fine.

However, in some cases, the filter request (parameter fq ) that is sent to Solr is quite large (it can be thousands of characters) and cannot be shortened. Since parsing the request takes only part of the total time , I want to experiment with this part of the request and send it to Solr.

I was thinking about changing the client, so instead of fq it uses a different parameter (e.g. zfq ). Then Solr can decide - if he gets zfq , he uses it and decodes the data in fq . Otherwise, he should behave as usual.

What is the standard way to achieve the above? It looks like there is SearchHandler , requestHandler , <queryParser (both in solrconfig.xml), and many others, and I'm not quite sure what is the least intrusive. I'm pretty sure about Lucene / Tomcat, but don't know much about Solr data structures.

+6
source share
2 answers

Have you ever thought about using this syntax -category: (1 2 3 4 ... N). This should reduce the string by 90%. Better than a clasp.

0
source

You can make your Solr container extremely long URLs: here Tomcat , Jetty here .

If the fq value has default values, you can create a query parser that includes it by default.

  <requestHandler name="for_some_queries" class="solr.SearchHandler" default="true"> <!-- default values for query parameters --> <lst name="defaults"> <str name="echoParams">explicit</str> <str name="fq">MY VERY LONG FQ</str> </lst> </requestHandler> 

But I agree with Mauricio Scheffer for a better design.

+1
source

Source: https://habr.com/ru/post/914647/


All Articles