Repository navigation
fix(query): stop dropping zero-valued hybrid combination params - #819
Merged
vishal-bala merged 3 commits intoNov 5, 2026
Merged
Conversation
build_combination_method checked linear_alpha, rrf_constant and rrf_window for truthiness, so an explicit 0 was treated as unset. linear_alpha=0 raised ValueError, or sent no weights when a score alias was set, and rrf_constant=0 fell back to the server default of 60. Compare against None so 0 reaches the server. Redis rejects WINDOW 0, so rrf_window=0 now returns the server's error instead of being ignored.
vishal-bala
self-requested a review
November 5, 2026 09:45
vishal-bala
requested changes
Nov 5, 2026
vishal-bala
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR! Just a few changes related to the tests mainly
Cover alpha=0 through test_hybrid_query_alpha and make its assertion two-sided, so a score that is too low also fails. Merge the RRF zero tests into one and drop cases that catch no additional revert.
An alpha of 0 or 1 only zeroes one side's score. Both searches still run, so point to VectorQuery and TextQuery for single-sided searches.
vishal-bala
self-requested a review
November 5, 2026 11:34
|
🚀 PR was released in |
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.
Motivation
build_combination_methodcheckslinear_alpha,rrf_constantandrrf_windowfor truthiness, so an explicit0is treated as if it were never passed.HybridQuery(..., combination_method="LINEAR", linear_alpha=0.0)raisesValueError: No parameters provided for combination method. Withyield_combined_score_asset it raises nothing and sends no weights at all, so the server applies its defaults.rrf_constant=0is replaced by the server's default of 60 without any signal, becauseHybridQueryalways sends a window.Changes
Treat 0 as a provided value
The three checks in
build_combination_methodnow compare againstNone, so a 0 reaches the server:linear_alpha=0.0scores by vector similarity only, the counterpart oflinear_alpha=1.0. Redis rejectsWINDOW 0, sorrf_window=0now returns the server'sWINDOW: Value below minimumerror instead of silently running with a different window.The
linear_alphadocstring and the advanced queries notebook now say both searches still run at 0 and 1, so useVectorQueryorTextQuerywhen only one is needed.Notes
build_base_queryhas similar truthiness checks onrange_radius,range_epsilonandknn_ef_runtime. They are left out because they aren't combination params and need different handling: the server acceptsRADIUS 0but rejectsEPSILON 0andEF_RUNTIME 0.Release Notes
HybridQuerynow honourslinear_alpha=0andrrf_constant=0, including MCPsearch.params.linear_text_weight: 0andrrf_constant: 0on native hybrid search. These values were previously dropped, so affected queries will rank differently, andrrf_window=0now returns a server error instead of being ignored.Reviewer Brief
Start here:
build_combination_methodinredisvl/query/hybrid.py. It's the only production logic change, and sync, async and MCP hybrid search all go through it.Where it could fail
redisvl/query/hybrid.py:337: a query or MCP config passingrrf_window=0used to run and now gets a server error; nothing in the repo passes it.Not verified: a full MCP server run with these values (only the query arguments it builds); Redis Cluster, Redis Software and Redis Cloud. The docs don't state whether 0 is accepted for
ALPHAorCONSTANT, so that rests on the runs against Redis 8.4.8 and 8.10.3. The cost difference fromVectorQueryandTextQuerywasn't measured; the runs only confirm both searches still execute at alpha 0 and 1.Beyond CI: reverting each of the three checks on its own fails only the regression tests for that parameter; the tests also pass on redis-py 7.1.0 and 7.4.1.
Since the last brief:
f91c0a4consolidates the zero-value tests and makes thetest_hybrid_query_alphaassertion two-sided;3feccd1documents that both searches run at alpha 0 and 1. No production logic changed.Reviewed
fd4bc4c· Claude Code (claude-opus-5-5) · lenses: correctness, security, design, tests, docs, Redis behaviourNote
Medium Risk
Queries that previously passed 0 for combination params will rank differently now;
rrf_window=0may surface a Redis server error instead of being ignored silently.Overview
HybridQuery no longer treats
linear_alpha=0,rrf_constant=0, orrrf_window=0as “unset.” Inbuild_combination_method,rrf_window,rrf_constant, andlinear_alphaare included when they are explicitly provided (checked withis not None) instead of being skipped because they are falsy. Those values are forwarded to Redis asALPHA/BETA,CONSTANT, andWINDOWrespectively, so linear all-vector weighting and RRF with constant 0 behave as configured instead of falling back to server defaults or raising “no parameters provided.”Docs and docstrings clarify that at
alpha0 or 1 hybrid search still runs both text and vector legs—only the combined score is single-modality— and suggestTextQuery/VectorQuerywhen one leg is enough. Tests coveralpha=0.0, serialized RRF params at zero, and integration behavior forrrf_constant=0.Reviewed by Cursor Bugbot for commit 3feccd1. Bugbot is set up for automated code reviews on this repo. Configure here.