d-_-b
d-_-b

Reputation: 23211

ZINTERSTORE keep score of one set

Am I correct that this is not possible with redis?

ZINTERSTORE two zsets (A and B), and have the output set's score equal to zset B's scores?

I think the only ways are AGGREGATE SUM|MIN|MAX, so I don't think my use case can be done. Set A's score is not predictable so can't just subtract the two.

ZINTERSTORE out 2 setA setB returns scores of 0

Upvotes: 2

Views: 432

Answers (1)

Itamar Haber
Itamar Haber

Reputation: 50112

You can use ZINTERSTORE's WEIGHTS option to give setA weight of 0 and 1 for setB:

ZINTERSTORE out 2 setA setB WEIGHTS 0 1

This will multiply A's scores by 0 and keep B's scores as is.

Upvotes: 4

Related Questions