feat(search): add COLLECT reducer for FT.AGGREGATE (Redis 8.8+)#3840
Open
ndyakov wants to merge 4 commits into
Open
feat(search): add COLLECT reducer for FT.AGGREGATE (Redis 8.8+)#3840ndyakov wants to merge 4 commits into
ndyakov wants to merge 4 commits into
Conversation
Add the new in-group sorting reducer for FT.AGGREGATE introduced in Redis 8.8. COLLECT unwinds grouped documents after GROUPBY and projects them as an array of key/value maps, with optional FIELDS, DISTINCT, SORTBY, and LIMIT clauses. The existing FTAggregateReducer plumbing already passes Args verbatim after the reducer name, so the only changes needed are: - Add SearchCollect to the SearchAggregator enum. - Map SearchCollect.String() to "COLLECT". Unit tests cover the String() mapping for every SearchAggregator constant and assert that FTAggregateWithArgs emits the expected REDUCE COLLECT ... AS ... clause for a representative query. See: https://redis.io/docs/latest/develop/whats-new/8-8/
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds client support for Redis 8.8+ FT.AGGREGATE COLLECT reducer by extending the existing SearchAggregator enum and its string mapping, plus unit tests validating reducer name rendering and command argument emission.
Changes:
- Add
SearchCollectto theSearchAggregatorenum. - Map
SearchCollect.String()to"COLLECT". - Add unit tests for
SearchAggregator.String()andFTAggregateWithArgsemittingREDUCE COLLECT ... AS ....
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| search_commands.go | Adds SearchCollect enum value and String() mapping to "COLLECT". |
| search_commands_unit_test.go | Adds unit tests for the new enum mapping and for FTAggregateWithArgs emitting a REDUCE COLLECT clause. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ofekshenawa
previously approved these changes
Jun 10, 2026
ofekshenawa
previously 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.
Add the new in-group sorting reducer for FT.AGGREGATE introduced in Redis 8.8. COLLECT unwinds grouped documents after GROUPBY and projects them as an array of key/value maps, with optional FIELDS, DISTINCT, SORTBY, and LIMIT clauses.
The existing FTAggregateReducer plumbing already passes Args verbatim after the reducer name, so the only changes needed are:
Unit tests cover the String() mapping for every SearchAggregator constant and assert that FTAggregateWithArgs emits the expected REDUCE COLLECT ... AS ... clause for a representative query.
See: https://redis.io/docs/latest/develop/whats-new/8-8/
p.s. no integration tests as of now this should be enabled on the redis side to pass.
Note
Low Risk
Enum and string mapping only; aggregate command assembly is unchanged and covered by new unit tests. COLLECT requires Redis 8.8+ on the server.
Overview
Adds client support for Redis 8.8’s COLLECT
FT.AGGREGATEgroup reducer by extendingSearchAggregatorwithSearchCollectand mapping it to"COLLECT"inString(). Callers can use the existingFTAggregateReducer/GroupByoptions; reducerArgs(e.g.FIELDS,SORTBY,LIMIT) are still passed through unchanged afterREDUCE COLLECT.Unit tests assert every aggregator’s
String()output (including COLLECT) and thatFTAggregateWithArgsbuilds the expectedREDUCE COLLECT … AS …command for a representative grouped query.Reviewed by Cursor Bugbot for commit 7b268d4. Bugbot is set up for automated code reviews on this repo. Configure here.