简体   繁体   中英

Redisearch equivalent for a MySQL query

I'm looking for the Redisearch equivalent of the following query:

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

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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