ソートされたセットのスコアは数値でなければならないため、交差/和集合操作でスコアの単純な連結を返すことはできません。
ただし、各セットのスコアの値を特定の範囲に制限できる場合は、SUM 演算を使用して、単純な算術演算で 2 つの値を 1 つの値にエンコードすることができます。
例:
# For s1, we assume the score is between 0 and 999
> zadd s1 100 key1 200 key2 300 key3
(integer) 3
# For s2, we assume the score is between 0 and 99
> zadd s2 1 key1 2 key2 3 key3
(integer) 3
# Get the intersection, dividing the s2 score by 100
> zinterstore s3 2 s1 s2 WEIGHTS 1 0.01
(integer) 3
# Get the result with scores
> zrange s3 0 -1 withscores
1) "key1"
2) "100.01000000000001"
3) "key2"
4) "200.02000000000001"
5) "key3"
6) "300.02999999999997"
結果のスコアでは、整数部分には s1 からのスコアが含まれ、小数部分には s2 からのスコアが含まれます。
スコアは倍精度浮動小数点数であることに注意してください。それにはいくつかの結果があります: