Search code examples
redisnode-redisredis-cli

How We can do partial search in Redis using SSCAN with special characters


I have created a Redis set and the following is the member of the set:

 "[test@#$demo%^here[sfs]][en-us][1234]"

I have 1000 members in the Redis set and I want to search this document using sscan partially I have tried following the way

 sscan test 0 match "[test@#$demo%^here[sfs]][en-us]" 

but is not working properly So how I can do it directly without looping?


Solution

  • Use the \ to escape a character that has special meaning inside a match expression. You can try:

    sscan test 0 match "\\[test@#$demo%^here\\[sfs]\\]\\[en-us\\]*"