简体   繁体   English

Apache Solr 在不指定字段名的情况下在整个集合中搜索一个字符串

[英]Apache Solr search a string in the entire collection without specifying the field name

I am looking for a way to search the given string in the entire collection.我正在寻找一种在整个集合中搜索给定字符串的方法。 I referred Correct use case of String parameter in SetQuery function of SolrQuery?在 SolrQuery 的 SetQuery 函数中提到了 String 参数的正确用例?

The provided example works for the scenario like this: query.setQuery("fieldName":"value") but it is not working for query.setQuery("*value*") .提供的示例适用于这样的场景: query.setQuery("fieldName":"value")但它不适用于query.setQuery("*value*") In my case, I don't want to provide the name of the field and it should search the entire collection no matter the field name which has this value.在我的情况下,我不想提供字段的名称,它应该搜索整个集合,而不管具有此值的字段名称。 Is there any other way for this scenario?这种情况还有其他方法吗?

Create a copy field named "text" in the schema.xml and copy all the fields to it.schema.xml创建一个名为"text"的复制字段,并将所有字段复制到其中。

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

In order to set default search field in solrconfig.xml file under /query request handler or as IntParams.为了在 /query 请求处理程序下的 solrconfig.xml 文件中设置默认搜索字段或作为 IntParams。

<requestHandler name="/query" class="solr.SearchHandler">
   <lst name="defaults">
     <str name="echoParams">explicit</str>
     <str name="wt">json</str>
     <str name="indent">true</str>
     <str name="df">text</str>
   </lst>
</requestHandler>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM