Redis OR check in MATCH

不羁的心 提交于 2019-12-11 05:42:21

问题


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:


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.



来源:https://stackoverflow.com/questions/40726516/redis-or-check-in-match

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!