jsonrediskeywildcard

redis-cli json key regex match


I am fairly new to redis. Started using redis with ':' separated namespaces to store pickle data. It's easier to search for what data is stored using wildcard searches on redis clients(redisinsights for example).

e.g. If data is stored in a hierarchal structure

key=source1:20240506:part1:subtype1:1 value=pickle(dataset1) key=source1:20240506:part2:subtype2:2 value=pickle(dataset2)

A scan on the client for example source1:202405* shows a list of keys that can be then individually explored.

The question now is, why isn't wildcard search on key/namespace supported if i use json.set instead ?

Whenever i tried a wildcard scan, no data is shown. However, data is shown if i use an exact key.


Solution

  • Works on my machine:

    127.0.0.1:6379> json.set source1:20240506:part1:subtype1:1 $ '{ "foo": "bar" }'
    OK
    127.0.0.1:6379> json.set source1:20240506:part1:subtype1:2 $ '{ "baz": "qux" }'
    OK
    127.0.0.1:6379> scan 0 MATCH source1:202405* COUNT 100
    1) "0"
    2) 1) "source1:20240506:part1:subtype1:2"
       2) "source1:20240506:part1:subtype1:1"
    

    Is this an accurate example of what you are running into? What version of Redis are you using?