[英]Redisearch equivalent for a MySQL query
I'm looking for the Redisearch equivalent of the following query:我正在寻找与以下查询等效的Redisearch :
NOT (topic_id = '123' AND post_id <= '456')
I tried the following - it works but doesn't look like the most elegant solution:我尝试了以下方法 - 它有效,但看起来不是最优雅的解决方案:
-(@topic_id:[123 123] @post_id:[-inf 456])
topic_id
and post_id
are NUMERIC and SORTABLE topic_id
和post_id
是NUMERIC和SORTABLE
Thanks for your help!谢谢你的帮助!
Chris, Your query looks perfectly valid, the only simplification I would apply is:克里斯,您的查询看起来完全有效,我要应用的唯一简化是:
-(@topic_id:123 @post_id:[-inf 456])
To avoid repeating the 123
value.避免重复
123
值。 The other option would be to use DeMorgan's law and rewrite your NOT(A AND B)
to (!A OR !B)
but I don't think that would buy you anything, and in this case it would make it harder to read I think.另一种选择是使用德摩根定律并将你的
NOT(A AND B)
重写为(!A OR !B)
但我认为这不会给你带来任何好处,在这种情况下它会让你更难阅读我思考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.