Redis OR check in MATCH

2019-07-27 08:58发布

As a beginner, I would like to know if there is a way to write below query in redis

Scan 0 MATCH Test:[keyword*:* | *:keyword]

Right now I have to do two separate scans for this query as below

Scan 0 MATCH Test:*:keyword*
Scan 0 MATCH Test:keyword*:*

1条回答
神经病院院长
2楼-- · 2019-07-27 09:52

I see that you've 3 choices here:

  1. Wrap both commands into a Lua script and call it as it would be a single command.

  2. Instead of scanning do indexing. Create a set or sorted set where you'll store all elements that matches these patterns, and just perform a a sscan or zscan with no MATCH.

  3. Keep doing it as you've done already.

查看更多
登录 后发表回答