mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-25 05:02:27 +00:00
fix: retain hybrid scores until reranking completes
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user