fix: retain hybrid scores until reranking completes

This commit is contained in:
Xuanwo
2026-10-23 20:41:16 +02:00
parent fa6fff632c
commit 3d4f93e431
3 changed files with 148 additions and 0 deletions
+34
View File
@@ -132,6 +132,40 @@ describe("Query outputSchema", () => {
},
);
it.each(["columns", "dynamic", "all"])(
"should keep hybrid search working with scoring autoprojection disabled (%s)",
async (projection) => {
await table.createIndex("text", { config: Index.fts() });
const query = () => {
const query = table.vectorSearch([1, 2]).fullTextSearch("foo");
if (projection === "columns") {
query.select(["a"]);
} else if (projection === "dynamic") {
query.select({ doubled: "a * 2" });
}
return query;
};
const expected = await query().toArrow();
const results = await query().disableScoringAutoprojection().toArrow();
const rows = (result: typeof results) =>
result.toArray().map((row) => ({
a: row.a,
doubled: row.doubled,
text: row.text,
vec: row.vec ? Array.from(row.vec) : undefined,
relevance: row._relevance_score,
}));
expect(results.numRows).toBe(3);
expect(rows(results)).toEqual(rows(expected));
expect(results.schema.fields.map((field) => field.name)).toEqual(
expected.schema.fields
.map((field) => field.name)
.filter((name) => name !== "_distance" && name !== "_score"),
);
},
);
it("should preserve the scoring option when converting to a vector query", async () => {
const results = await table
.query()