Sunday, August 10, 2014

[SOLR] How to join fl default parameters and request parameters?



If I have set of fields, specified in fl of some SearchRequestHandler configuration in xml, then fl specified in query request parameter will override fl specified in SearchRequestHandler configuration in xml.
I want that SOLR to do Join of fl parameters from query and from SearchRequestHandler instead of overriding it.
For example:
If in query I have fl=field1,field2 and in SearchRequestHandler configuration; I have fl=field3,field1 then join of these two as fl=field1,field2,field3. 
For this issue you can use following solution:
You can use <lst name="appends"> in your requestHandler definition to make Solr append the values to the query instead of replacing them. Since fl can be added several times to the same request, this works as you're extending the list of fields to retrieve.


<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="appends">
        <str name="fl">cat</str>
    </lst>
</requestHandler>



This solution will help you when you have too many fl fields that needs to defined and few of them changes as per the query.

No comments:

Post a Comment

Password Protected Solr Admin Page

As we all know Solr Admin Page is not password protected and anyone can get into Solr Admin Page. However this article will ...