[英]Solr query field fallback
I have the following fields indexed in Solr: 我在Solr中索引了以下字段:
I would like to search for a document where FIELD_3=X but if FIELD_3 is empty (or non existent in the document), to search in FIELD_2, and then in FIELD_1 我想搜索FIELD_3 = X的文档,但是如果FIELD_3为空(或文档中不存在),请在FIELD_2中搜索,然后在FIELD_1中搜索
Is this kind of query possible in Solr ? Solr中可以进行这种查询吗?
Thank you 谢谢
Assuming that you only want to search against FIELD2 and FIELD1 if the previous fields are empty (and not if they have a value, but it didn't generate a hit), something like: 假设您只想在先前的字段为空 (如果它们没有值,但是没有产生匹配)的情况下针对FIELD2和FIELD1进行搜索,则类似于:
q=FIELD3:foo OR (FIELD2:foo AND NOT FIELD3:[* TO *]) OR (FIELD1:foo AND NOT FIELD2:[* TO *] AND NOT FIELD3:[* TO *])
should work. 应该管用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.