Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr4 currently only looks at the default "df" field, how can we search multiple fields?

Tags:

solr

solr4

In Solr 4, I see that we've configured the default field "df" in the /select request handler:

  <requestHandler name="/select" class="solr.SearchHandler">
    <!-- default values for query parameters can be specified, these
         will be overridden by parameters in the request
      -->
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <int name="rows">10</int>
       <str name="df">id</str>

But id is our unique document field, so all queries are defaulting to "id:my_query", which always returns 0 results.

How do I define which fields should be queried by default?

This is an upgrade from v3 to v4 and this part of it seems to have been broken along the way.

like image 225
David Parks Avatar asked Mar 06 '13 08:03

David Parks


1 Answers

You can use a copy field named "text", copy all your searchable fields into this field and specify it as default search field.

<requestHandler name="/select" class="solr.SearchHandler">
    <!-- default values for query parameters can be specified, these
         will be overridden by parameters in the request
      -->
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <int name="rows">10</int>
       <str name="df">text</str>

You can add fields to be copied to a copy field as follows:

<copyField source="field1" dest="text"/>
<copyField source="field2" dest="text"/>
...
<copyField source="fieldn" dest="text"/>

Note that "text" is the copy field here.

like image 56
Mavellin Avatar answered Sep 23 '22 10:09

Mavellin