Wildcard in key for ReJson queries

Hi Team,
I was wondering if there was a way to use a wildcard in key for ReJson Commands?
For Example I have multiple json store with following keys:

  1. 11111:abc
  2. 11111:xyz
  3. 22222:abc
  4. 22222:yhj
    Now if I was to delete all json’s with keys of type 22222:* what approach should I take?
    I tried using wildcard in keys but didnt work.

To achieve this currently I will have to run.
JSON.DEL 22222:abc .
JSON.DEL 22222:yhj .

I wish there was a simpler way. Are such queries currently supported by ReJson?

Hi @ksinghddn

There are a few ways on going about it,

One way would be to cloning to a new document, e.g. copying all the needed fields instead of removing the keys, this would have resulted in more efficient operation and reduces I/O load.

Another way, you can build a helper function, e.g. in luascript that allows you to scan and delete multiple fields: https://redis.io/commands/eval


likewise Redis is key-value database, its always preferred to do key specific operations. but saying that you have some work around here but it depends how the keys are created and use case operations.

  1. using lua script for multi-key operation - scan and delete - dont forget that I needs all keys in same shard
  2. using redisgears - works on background thread much modern way to handle such case
  3. use index list - ex. I would store all the keynames specific to mapping key, as per your example I will keep keys of type 22222 in Redis Sets when those are created and then use it to fetch all keynames to perform DEL operation.
  4. so on …

hope this helps.