Reputation: 16622
I have two different sorted sets.
One is for editor ID:
article_id editor_id
101 10
102 11
103 10
104 10
The other sorted set is for date sorting:
article_id day
101 29
102 27
103 25
104 27
I want to merge these sets which shows first editor second day sorted state. Which commands should I use?
Upvotes: 0
Views: 483
Reputation: 49942
Assuming that article_id
is your members' value and that editor_id
/day
are the scores in the respective Sorted Set, and assuming each article_id
is present in both Sorted Sets, you can do the following:
ZINTERSTORE t 2 k1 k2 WEIGHTS 100 1 AGGREGATE SUM
Explanation:
t
is a temporary key that will hold the resultk1
is the Sorted Set that stores the editor_id
k2
is the Sorted Set that stores the day
editor_id
by 100 (i.e. "shifts" it two places to the right)AGGREGATE SUM
results in the following score: editor_id
* 100 + day
Notes:
ZUNIONSTORE
instead for the same resultday
is a 2-digit valueUpvotes: 3