J. Chris
J. Chris

Reputation: 21

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!

Upvotes: 2

Views: 428

Answers (1)

BSB
BSB

Reputation: 1705

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.

Upvotes: 3

Related Questions