shantanuo
shantanuo

Reputation: 32296

Inner Joins in redis

I have a problem that is very similar to one mentioned here...

https://grokbase.com/t/gg/redis-db/123wv39cnt/filtering-zset-by-hash-field-value

But I am not able to understand the answer provided in that thread.

zadd scores 1.0 mary
zadd scores 2.0 sue
zadd scores 3.0 bob
zadd scores 4.0 bruce
zadd scores 5.0 maggie

sadd females mary sue maggie

zinterstore femscores 2 scores females

zrange femscores 0 50 withscores

How are the values 2, 3 and 6 calculated?

1) "mary"
2) "2"
3) "sue"
4) "3"
5) "maggie"
6) "6"

Upvotes: 1

Views: 205

Answers (1)

LeoMurillo
LeoMurillo

Reputation: 6754

It is the result of the default WEIGHTS and AGGREGATE as described in ZUNIONSTORE.

Default WEIGHTS is 1, default AGGREGATE is SUM, so you are seeing the scores incremented by 1.

If you want the scores score without modification, simply set to zero the weight for females:

ZINTERSTORE femscores 2 scores females WEIGHTS 1 0

Upvotes: 1

Related Questions