Skip to content

Missing aggregation type "COUNT" of ZUNIONSTORE #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ts-thomas opened this issue Apr 15, 2025 · 2 comments
Closed

Missing aggregation type "COUNT" of ZUNIONSTORE #1416

ts-thomas opened this issue Apr 15, 2025 · 2 comments

Comments

@ts-thomas
Copy link

I couldn't find a way how to properly stack up the count of union matches to the calculation.

This is what I theoretically need:

// a set of keys
keys = [ .... ];
// initial weights to 1
weights = [ 1, 1, 1, ....];

// store union with COUNT as the new score
redis.zUnionStore(dest, keys, { AGGREGATE: "COUNT" });

// push the destination to the keys
keys.push(dest);
// add some high value to the weights to prefer the
// ordering based on count over the sum of score
weights.push(999);

// calculate final results with the right ordering
redis.zUnionStore(dest, keys, { WEIGHTS: weights, AGGREGATE: "SUM" });

In SQL something simliar is ORDER BY count DESC, score DESC

Is there a chance to add such functionality to the library? Thanks in advance

@dwdougherty
Copy link
Collaborator

Hi @ts-thomas. I suggest you ask your question on the Redis Discord channel. You might get some creative ideas of how to accomplish this in the absence of this feature. Alternatively, you can raise an issue on the Redis repo itself.

@ts-thomas
Copy link
Author

@dwdougherty Thanks a lot for the quick response. The Discord was a nice hint 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants