在 Solr 中搜索日期范围或空/无字段 [英] Searching for date range or null/no field in Solr

查看:25
本文介绍了在 Solr 中搜索日期范围或空/无字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对 Solr 中的文本字段执行搜索.我想返回范围内或没有值的所有匹配项.两者独立查词:

I want to perform a search on a text field in Solr. I want to return all matches in a range or where there is no value. The two searches word independently:

myfield:[start TO finish]
-myfield:[* TO *]

第一个返回范围内的所有匹配项.第二个返回所有对myfield"字段没有值的匹配项.问题在于将这两者结合起来.

The first returns all matches in the range. The second returns all matches that have no value for the "myfield" field. The problem is combining these two.

这不返回匹配项:

myfield:[start TO finish] OR -myfield:[* TO *]

这将返回开始和结束之间的匹配,但不返回空条目:

This returns matches between start and finish, but not null entries:

myfield:[start TO finish] OR (-myfield:[* TO *])

推荐答案

Mauricio Scheffer 的解决方案对我有用,直到我将其包含在完整查询中.查询本身可能包含最多三个具有范围的字段,并且在中间的某个地方 Solr 无法处理它.我已经设法通过下一个查询解决了它:

The solution from Mauricio Scheffer worked for me until I've included it into full query. The query itself may contain up to three fields with ranges and somewhere in the middle Solr failed to process it. I have managed to solve it with next query:

(myfield:[start TO finish] OR (*:* NOT myfield:[* TO *]))

即使在我复杂的查询中它也能唤醒,所以也许它会帮助其他人.

It woked even in my complex query, so maybe it will help someone else.

这篇关于在 Solr 中搜索日期范围或空/无字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆