How can I Ignore some fields in a SOLR query

给你一囗甜甜゛ 提交于 2019-12-06 08:07:43

Use copyField

Here is how you can use this:

  • Make all the field stored="true" and indexed="false"
  • Also create a new field say cffield with multiValued="true", stored="false" and indexed="true"

Example Schema :

<field name="field1" type="string" indexed="false" stored="true"/>
<field name="field2" type="string" indexed="false" stored="true"/>
<field name="field3" type="string" indexed="false" stored="true"/>
....
<field name="cffield" type="string" indexed="true" stored="false" multiValued="true"/>
  • Now all the field from you want to search, set source value of use copyField tag to copy from source field to dest

Example Schema :

<copyField source="field1" dest="cffield"/>
<copyField source="field2" dest="cffield"/>
....

Now you can search using

query = cffield:txtSearch

This will give you result from all the field you use copyField's source and cffield as dest

indexed="false" needs to be mentioned in the schema.xml.

Once you modify the schema.xml, you need to re-index the data.(you need to re-start the server as well)

Then solr will not search in the fields which are not indexed. And if you want to search in specific field you can use the field name and the search value for the field.

like

   `q=field1:"value1"`
    q=field1:value1 OR field2:value2
    q=field1:value1 AND field2:value2
    q=value1&fq=field2:value2&fq=field3:value3  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!