11

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,.

Praditha
  • 1,162
  • 5
  • 24
  • 45

3 Answers3

11

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.

Ravindra S
  • 6,302
  • 12
  • 70
  • 108
Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • 3
    This is no longer true since Solr 3.6 and later. See https://issues.apache.org/jira/browse/SOLR-2724 – kellyfj Dec 15 '15 at 16:47
5

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

kellyfj
  • 6,586
  • 12
  • 45
  • 66
4

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.

jpountz
  • 9,904
  • 1
  • 31
  • 39
  • if like that, it still must specify the fields that will be in search right,.? and what is the character ^1 mean,.? – Praditha Nov 29 '11 at 03:36
  • Yes you need to specify every field. The '^' character gives you the ability to give weights to your field. For example, if a match in `field1` should be twice as important as a match in `field2`, you could use `qf=field1^2 field2^1`. – jpountz Nov 29 '11 at 13:48