删除 solr 查询语法中的过期记录

发布于 2024-08-23 14:44:53 字数 501 浏览 3 评论 0原文

我在 solr 1.4 上遇到了 solr 查询语法问题(我认为)。我正在尝试从 solr 查询中排除过期记录。但是,如果该记录没有过期记录,我也想将该记录带回来。例如,

为了仅获取尚未过期的记录列表,我正在使用此查询:

expirydate:[NOW/DAY TO *]

然后我想获取一个没有有过期日期的记录列表,我可以使用

-expirydate:[* TO *]

这两个查询都 可以使用他们自己的。即第一个查询返回 3 条记录。第二个查询返回 921 条记录。然而,当我将 2 个查询与 OR 组合在一起时,我得到 0 条记录:

expirydate:[NOW/DAY TO *] OR -expirydate:[* TO *]

知道我做错了什么吗?

谢谢

戴夫

I'm having a solr query syntax issue (I think) with solr 1.4. I'm trying exclude expired records from a solr query. However if the record doesn't have an expiry record, i would like to bring that record back also. E.g.

To only get a list of record that haven't expired i am using this query:

expirydate:[NOW/DAY TO *]

Then I thought to get a list of records which don't have an expiry date i can use

-expirydate:[* TO *]

Both queries work on their own. I.e. the first query brings back 3 records. The 2nd query brings back 921 records. However when I combine the 2 queries together with an OR I get 0 records:

expirydate:[NOW/DAY TO *] OR -expirydate:[* TO *]

Any ideas what I'm doing wrong?

Thanks

Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橙味迷妹 2024-08-30 14:44:53

这里不是 100% 确定,但我认为你不能以这种方式将 OR 与否定运算符结合起来。

尝试在每个文档中添加具有相同值的虚拟字段并尝试

enddate:[NOW/DAY TO *] OR (dummy:yes -enddate:[* TO *])

Not 100% sure here, but I don't think you can combine OR with the negation operator in this manner.

Try adding a dummy field with the same value in every document and try

enddate:[NOW/DAY TO *] OR (dummy:yes -enddate:[* TO *])
故人爱我别走 2024-08-30 14:44:53

我只需要解决这个问题,我就开始实施已批准的答案,但后来意识到我可以这样做:

-过期日期:[* 到现在]

无论文档是否设置了过期日期,该方法都有效。

I just had to tackle this problem, I went about implementing the approved answer but then realized that I could just do this:

-expired-date:[* TO NOW]

That worked regardless if the document had expired-date set.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文