feat(search): add COLLECT reducer to FT.AGGREGATE#3310
Open
nkaradzhov wants to merge 1 commit 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>
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, 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
GROUPBYreducer onFT.AGGREGATE, so callers can gather full documents or selected fields per group with optional DISTINCT, in-group SORTBY, LIMIT, and AS aliases.parseGroupByReducernow emits the Redis wire format for COLLECT:FIELDS *vs count-prefixed field lists, optional clauses, and a dynamically computed nargs viapushVariadicWithLength(reusingpushSortByPropertyfor nested sort). Types extendGroupByReducerswith aCollectReducershape.Coverage includes unit tests for argument transformation (including real-world-style examples) and an integration test against a new
OPEN_UNSTABLEtest 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.