ojoaovitoraraujo
ojoaovitoraraujo

Reputation: 97

How to perform a multi-hash redis query

I have multiple hash-keys organized in "folders" like MOC273,

127.0.0.1:6379> HMSET MOC273:123654789 "H_W" "json->H_W->123654789" "H_Y" "json->H_Y->123654789"
OK
127.0.0.1:6379> HMSET MOC273:987654321 "H_W" "json->H_W->987654321" "H_Y" "json->H_Y->987654321"
OK

With HGETALL I can get all the data from a hash

127.0.0.1:6379> HGETALL  MOC273:123654789
1) "H_W"
2) "json->H_W->123654789"
3) "H_Y"
4) "json->H_Y->123654789"

How can I get all the hashes contained in MOC273(where the name starts with MOC273) Something like.

127.0.0.1:6379> HGETALL MOC273*

It's possible ?

Current structure of the redis

Upvotes: 1

Views: 289

Answers (1)

namizaru
namizaru

Reputation: 824

So you can use Redisearch to create a secondary index around the HASH data structure. This will allow you to search through HASH data more efficiently.

https://oss.redis.com/redisearch/ - Quick start should help you to get started

Upvotes: 1

Related Questions