Skip to content

feat(search): add COLLECT reducer for FT.AGGREGATE (Redis 8.8+)#3840

Open
ndyakov wants to merge 4 commits into
masterfrom
ndyakov/ft-aggregate-collect-reducer
Open

feat(search): add COLLECT reducer for FT.AGGREGATE (Redis 8.8+)#3840
ndyakov wants to merge 4 commits into
masterfrom
ndyakov/ft-aggregate-collect-reducer

Conversation

@ndyakov

@ndyakov ndyakov commented Jun 3, 2026

Copy link
Copy Markdown
Member

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/

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.AGGREGATE group reducer by extending SearchAggregator with SearchCollect and mapping it to "COLLECT" in String(). Callers can use the existing FTAggregateReducer / GroupBy options; reducer Args (e.g. FIELDS, SORTBY, LIMIT) are still passed through unchanged after REDUCE COLLECT.

Unit tests assert every aggregator’s String() output (including COLLECT) and that FTAggregateWithArgs builds the expected REDUCE 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.

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/
@ndyakov ndyakov requested a review from ofekshenawa June 3, 2026 16:35
@ndyakov ndyakov self-assigned this Jun 3, 2026
@ndyakov ndyakov added the feature label Jun 3, 2026
@jit-ci

jit-ci Bot commented Jun 3, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SearchCollect to the SearchAggregator enum.
  • Map SearchCollect.String() to "COLLECT".
  • Add unit tests for SearchAggregator.String() and FTAggregateWithArgs emitting REDUCE 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.

Comment thread search_commands_unit_test.go
ofekshenawa
ofekshenawa previously approved these changes Jun 10, 2026
ofekshenawa
ofekshenawa previously approved these changes Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants