Summary
hybridQuery currently assigns 2x RRF weight by list position (i < 2) rather than by query intent/type.
In the common path (when expansion includes lex), this gives 2x to:
original FTS
- first
lex FTS
instead of the intended:
original FTS
original vec
Description
Current Behavior
In src/store.ts (hybridQuery, Step 4):
const weights = rankedLists.map((_, i) => i < 2 ? 2.0 : 1.0);
Push order before Step 4 is typically:
initialFts (original FTS)
lex FTS results (from expansion, Step 3a)
original vec results (Step 3b)
- expanded
vec / hyde
If any lex expansion exists, it occupies index 1, receiving the 2.0x weight, while the original vector query (the primary semantic signal) is pushed to index 2+ and receives only 1.0x.
Expected Behavior
2x weight should apply to lists whose queryType === "original" (i.e., original FTS + original vec), and expansion-derived lists should stay at 1x.
Proposed Fix
Use rankedListMeta (already built in parallel with rankedLists) to assign semantic weights:
const weights = rankedListMeta.map(meta =>
meta.queryType === "original" ? 2.0 : 1.0
);
Questions
- Does this alignment with the original design intent make sense to the maintainers?
- I have a local fix ready. Should I target the main branch or a specific development branch for the PR?
Summary
hybridQuerycurrently assigns 2x RRF weight by list position (i < 2) rather than by query intent/type.In the common path (when expansion includes
lex), this gives 2x to:original FTSlex FTSinstead of the intended:
original FTSoriginal vecDescription
Current Behavior
In
src/store.ts(hybridQuery, Step 4):Push order before Step 4 is typically:
initialFts(original FTS)lexFTS results (from expansion, Step 3a)originalvec results (Step 3b)vec/hydeIf any
lexexpansion exists, it occupies index 1, receiving the 2.0x weight, while the original vector query (the primary semantic signal) is pushed to index 2+ and receives only 1.0x.Expected Behavior
2x weight should apply to lists whose
queryType === "original"(i.e., original FTS + original vec), and expansion-derived lists should stay at 1x.Proposed Fix
Use
rankedListMeta(already built in parallel withrankedLists) to assign semantic weights:Questions