feat(query): allow unordered vector and full-text search results (#5328)

## Summary

Callers that consume every selected hit can relax the final output order
with `ordered_results(false)` in Rust, `ordered_results(False)` in
Python, or `orderedResults(false)` in TypeScript. Ranked output remains
the default. The option preserves top-k selection, each hit’s score and
projected columns, and the existing rules for ties at the cutoff.

Embedded passes eligible queries to the Lance scanner. Enterprise sends
`"ordered": false` for eligible searches and omits the field by default.
Explicit sorting, positive offsets, batch vector queries and inputs to
hybrid fusion or reranking keep their existing order.

## Validation

A managed Linux preview passed 8 Rust wire cases, 4 Embedded Python
cases, 10 HTTP mock cases and all 52 TypeScript query tests. The preview
used a candidate Lance revision. Project CI on this PR validates the
integration with the official Lance `v16.0.0-beta.6`.

Uses the official Lance dependency from #5327, now merged into `main`.
This commit is contained in:
Yang Cen
2026-12-01 20:41:37 +08:00
committed by GitHub
parent 0da2b7b307
commit 155457d0e5
17 changed files with 366 additions and 10 deletions
+20
View File
@@ -41,6 +41,26 @@ describe("Search subquery filters", () => {
tmpDir.removeCallback();
});
it.each(["vector", "fts"])(
"%s search preserves the selected rows when delivery order is relaxed",
async (kind) => {
const search = () =>
(kind === "vector"
? chunks.vectorSearch([0, 0])
: chunks.search("cat", "fts")
).limit(1);
const ranked = await search().toArray();
expect(ranked.map((row) => row[documentIdColumn])).toEqual(["AAA"]);
const scoreColumn = kind === "vector" ? "_distance" : "_score";
const hits = (rows: typeof ranked) =>
rows.map((row) => [row[documentIdColumn], row[scoreColumn]]);
expect(typeof ranked[0][scoreColumn]).toBe("number");
expect(hits(await search().orderedResults(false).toArray())).toEqual(
hits(ranked),
);
},
);
it.each(["vector", "fts"])(
"%s search prefilters by keys from another table",
async (kind) => {