Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The correct way of adding custom query parameter in Solr

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

However, in some cases the filter query (fq parameter) which is sent to Solr is quite large (can be thousands of characters) and can not be trimmed down. As the query parsing takes only a fraction of the overall time, I want to experiment with zipping this query part and sending it to Solr.

I was thinking of modifying the client so instead of fq it uses another parameter (e.g. zfq). Solr can then decide - if it receives zfq, it uses it and decodes the data into fq. Otherwise it should behave as usual.

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

like image 458
mindas Avatar asked May 01 '12 16:05

mindas


1 Answers

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

If the fqs have some 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.

like image 163
Jesvin Jose Avatar answered Oct 18 '22 04:10

Jesvin Jose