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,.
Asked
Active
Viewed 2.0k times
3 Answers
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
-
3This 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
-
after doing so, while searching giving error 'undefined field text' – Vishnu Sharma Jan 14 '18 at 07:26
-
-
-
In our configuration this is defined in solrconfig.xml `
allText ` so my guess you need to define the appropriate field in the schema - in our case the field is called 'allText' – kellyfj Jan 25 '18 at 15:22
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