How can I search all field in SOLR that contain th

2019-01-15 13:01发布

问题:

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

回答1:

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.



回答2:

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.



回答3:

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



标签: solr field