Skip to content

Count YIELD_SCORE_AS tokens in FT.HYBRID COMBINE clause #3811 - #3832

Merged
a-TODO-rov merged 2 commits into
redis:mainfrom
apoorva-01:fix/ft-hybrid-combine-yield-score-as-3811
Jul 10, 2026
Merged

a-TODO-rov merged 2 commits into
redis:mainfrom
apoorva-01:fix/ft-hybrid-combine-yield-score-as-3811

Conversation

@apoorva-01

@apoorva-01 apoorva-01 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Make sure that:

Combiners.rrf().window(20).constant(60).as("score") serializes the COMBINE clause as RRF 4 WINDOW 20 CONSTANT 60 YIELD_SCORE_AS score, but that count only covers the four combiner params. The YIELD_SCORE_AS score pair falls outside it, so Redis rejects the command as an unknown argument. Any hybrid query that sets a score alias is broken.

The count is written in Combiner.build() before the alias is appended, so I add the two tokens when an alias is set. It's on the final base, so RRF and LINEAR both pick it up. Jedis fixed the twin issue the same way (redis/jedis#4575).

This is @Experimental, so one to confirm: the fix assumes the count has to include YIELD_SCORE_AS to match how the server parses the clause. If you'd prefer an integration test against a live Redis too, I'll add one.

Heads up: #3831 opened for the same issue while I was wrapping this up. I put mine together independently and it mirrors the Jedis fix, so I'm sending it as an alternative. Glad to defer to whichever you'd rather take.

closes #3811


Note

Low Risk
Narrow serialization fix in experimental hybrid search command building, with unit and integration coverage and no change when no score alias is used.

Overview
Fixes broken FT.HYBRID COMBINE clauses when a combined score alias is set via Combiners.*.as(...). Redis expects the numeric token count after RRF/LINEAR to cover every following combiner argument, including the YIELD_SCORE_AS + alias pair; previously only combiner params (e.g. WINDOW, CONSTANT) were counted, so the server treated the alias as an invalid extra argument.

Combiner.build() now adds 2 to that count when scoreAlias is set, which applies to both RRF and LINEAR through the shared base class. Unit tests lock the serialized command strings for alias and no-alias cases; the hybrid integration test uses .as("combined_score") on the combiner and asserts combined_score, text_score, and vector_score appear in results.

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

apoorva-01 and others added 2 commits July 9, 2026 16:09
The clause count left out the YIELD_SCORE_AS pair, so Redis rejected any
hybrid query that set a combined-score alias.
@a-TODO-rov
a-TODO-rov merged commit c2d6d6f into redis:main Jul 10, 2026
12 checks passed
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.

FT.HYBRID COMBINE arg count omits YIELD_SCORE_AS tokens, command rejected when combined-score alias is set

2 participants

⌂ 换网址