sapwood
sapwood

Reputation: 61

Solr fl default parameters and fl request parameters join

Question is about returning fields.

If I have set of fields, specified in fl of some RequestHandler configuration in xml, then fl specified in query will override fl specified in RequestHandler configuration in xml. Is there any way to force solr to do OR between two fl values (not override, but join): from query and from RequestHandler configuration in xml?

For example, if in query I have fl=field1,field2 and in RequestHandler xml configuration I have fl=field3,field1 then join of these two will be fl=field1,field2,field3 and this is what will be run in final query.

I want to use fl values specified in RequestHandler configuration xml, because they are too many (~20) and I don't want to specify them all on each request.

Thank you!

Upvotes: 1

Views: 555

Answers (1)

MatsLindh
MatsLindh

Reputation: 52892

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>

Unless the client provides a list of fields, just cat will be returned. If it includes a fl parameter, they'll both be active.

Upvotes: 4

Related Questions