Skip to content

feat(search): add COLLECT reducer to FT.AGGREGATE#3310

Open
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:collect-aggregate
Open

feat(search): add COLLECT reducer to FT.AGGREGATE#3310
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:collect-aggregate

Conversation

@nkaradzhov

@nkaradzhov nkaradzhov commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

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)

Description

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Low Risk
Additive, opt-in aggregate reducer parsing and tests; no changes to auth, data paths, or existing reducer behavior beyond shared parseGroupByReducer.

Overview
Adds client support for the experimental COLLECT GROUPBY reducer on FT.AGGREGATE, so callers can gather full documents or selected fields per group with optional DISTINCT, in-group SORTBY, LIMIT, and AS aliases.

parseGroupByReducer now emits the Redis wire format for COLLECT: FIELDS * vs count-prefixed field lists, optional clauses, and a dynamically computed nargs via pushVariadicWithLength (reusing pushSortByProperty for nested sort). Types extend GroupByReducers with a CollectReducer shape.

Coverage includes unit tests for argument transformation (including real-world-style examples) and an integration test against a new OPEN_UNSTABLE test server (--search-enable-unstable-features yes) that asserts grouped results expose the COLLECT alias as an array of per-document maps.

Reviewed by Cursor Bugbot for commit 2629f36. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
@nkaradzhov nkaradzhov requested a review from PavelPashov June 17, 2026 12:35
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

Successfully merging this pull request may close these issues.

1 participant