feat(search): add COLLECT reducer to FT.AGGREGATE#3310
Open
nkaradzhov wants to merge 2 commits into
Open
Conversation
Support the experimental COLLECT reducer (Redis Search 8.8), which fetches whole documents or projected fields within each GROUPBY group, with optional DISTINCT, in-group SORTBY, and LIMIT. - FIELDS '*' emits a bare wildcard token; an explicit list is count-prefixed - nargs is computed dynamically via pushVariadicWithLength (unlike the fixed-narg reducers), covering FIELDS/DISTINCT/SORTBY/LIMIT - reuses pushSortByProperty for the nested SORTBY clause - HYBRID picks up COLLECT automatically (shared parseGroupByReducer) Tests: arg-serialization specs plus an integration test gated behind a new OPEN_UNSTABLE server config (--search-enable-unstable-features yes), required because COLLECT is rejected when unstable features are off. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
COLLECT reducer is only available on RediSearch >= 8.8 (behind --search-enable-unstable-features). Older matrix servers (7.4/8.2/8.4) reject it with "No such reducer: COLLECT". Gate the live test with minimumDockerVersion so it skips on those and runs on 8.8. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5c13988 to
25904dd
Compare
PavelPashov
reviewed
Jun 22, 2026
Comment on lines
+392
to
+394
| if (reducer.DISTINCT) { | ||
| args.push('DISTINCT'); | ||
| } |
Contributor
There was a problem hiding this comment.
Can you please check if this is correct, I get the following error:
Error: SEARCH_PARSE_ARGS Bad arguments for COLLECT: DISTINCT: Unknown argument
Collaborator
Author
There was a problem hiding this comment.
Turns out DISTINCT is not yet merged: RediSearch/RediSearch#9982
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 8a7ece9. Configure here.
8a7ece9 to
25904dd
Compare
PavelPashov
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Support the experimental COLLECT reducer (Redis Search 8.8), which fetches whole documents or projected fields within each GROUPBY group, with optional DISTINCT, in-group SORTBY, and LIMIT.
Description
Checklist
npm testpass with this change (including linting)?Note
Low Risk
Additive search client API and command serialization with broad test coverage; no changes to auth, data persistence, or existing reducer behavior.
Overview
Adds client support for the experimental COLLECT
GROUPBYreducer onFT.AGGREGATE(Redis Search 8.8+), so callers can return full documents or selected fields per group with optional in-group SORTBY, LIMIT, and AS aliases.parseGroupByReducernow emits the COLLECT wire format:FIELDS *vs count-prefixed field lists, dynamic nargs viapushVariadicWithLength, and reuse ofpushSortByPropertyfor nested sort clauses. A newCollectReducertype extends the publicGroupByReducersunion.Tests cover argument transformation (including real-world-style examples) and an integration case against Redis started with
--search-enable-unstable-features, gated to Docker 8.8 via a newGLOBAL.SERVERS.OPEN_UNSTABLEpreset.Reviewed by Cursor Bugbot for commit 8a7ece9. Bugbot is set up for automated code reviews on this repo. Configure here.