What happens
A filtered query on SQLiteVecVectorStore returns far fewer matches than limit even when enough records match the filter. Measured on main at ad8ff24b0: a collection of 1,000 records of 8 dimensions, 100 of them with a = 1; a query filtered on a = 1 returns 1 record at limit=10 and 2 records at limit=50. SQLiteVectorStore and the server-backed stores return limit records for the same data.
Why
The store asks sqlite-vec's KNN for the limit nearest rows of the whole collection and applies the property filter to those rows afterward, so only the nearest rows that happen to match survive. The more selective the filter, the fewer results come back, down to none.
Expected
A filtered query returns up to limit of the nearest records that match the filter, as the other stores do: the filter selects the candidates the KNN ranks, not the KNN's output.
Fix
#1628 hands sqlite-vec's KNN a rowid IN (SELECT ...) allowlist of the rows the filter admits, evaluating the filter during the search instead of after it.
🤖 Written by Claude Code (Claude Opus 5.5) on behalf of @edwinyyyu.
What happens
A filtered query on
SQLiteVecVectorStorereturns far fewer matches thanlimiteven when enough records match the filter. Measured onmainatad8ff24b0: a collection of 1,000 records of 8 dimensions, 100 of them witha = 1; a query filtered ona = 1returns 1 record atlimit=10and 2 records atlimit=50.SQLiteVectorStoreand the server-backed stores returnlimitrecords for the same data.Why
The store asks sqlite-vec's KNN for the
limitnearest rows of the whole collection and applies the property filter to those rows afterward, so only the nearest rows that happen to match survive. The more selective the filter, the fewer results come back, down to none.Expected
A filtered query returns up to
limitof the nearest records that match the filter, as the other stores do: the filter selects the candidates the KNN ranks, not the KNN's output.Fix
#1628 hands sqlite-vec's KNN a
rowid IN (SELECT ...)allowlist of the rows the filter admits, evaluating the filter during the search instead of after it.🤖 Written by Claude Code (Claude Opus 5.5) on behalf of @edwinyyyu.