Praditha
Praditha

Reputation: 1172

How can I search all field in SOLR that contain the keywords,.?

For example, I've keyword for search is: 'Basket Ball'. What is the query that can get all field that contain the 'Basket Ball',.? I've tried to using *:Basket Ball, but it doesn't work,.

Upvotes: 11

Views: 20200

Answers (3)

kellyfj
kellyfj

Reputation: 6973

The default search field (since 3.6) is now defined in solrconfig.xml

e.g. In the solrconfig.xml that ships with Solr configsets directory you will see something like

  <initParams path="/update/**,/query,/select,/tvrh,/elevate,/spell">
    <lst name="defaults">
      <str name="df">allText</str>
    </lst>
  </initParams>

You can change allText to yourDefaultSearchFieldName

Upvotes: 5

Jayendra
Jayendra

Reputation: 52809

schema.xml defines the default search field -

<defaultSearchField>text</defaultSearchField>

You can copy all the fields to this default search field.

<copyField source="field1" dest="text"/>
<copyField source="field2" dest="text"/>
<copyField source="field3" dest="text"/>

And query q=basket ball should work.

Upvotes: 11

jpountz
jpountz

Reputation: 9964

You need to use a query parser which is able to dispatch tokens to several fields, such as (e)dismax. For exemple if you have two fields field1 and field2: http://solr/select?q={!dismax}Basket Ball&qf=field1^1 field2^1

See http://wiki.apache.org/solr/DisMaxQParserPlugin#qf_.28Query_Fields.29 for more information on dismax configuration.

Upvotes: 4

Related Questions