sqlite-vec vec0 KNN: `col != ?` filters inside the search, but `NOT IN (...)` filters after LIMIT
With sqlite-vec 0.1.9, a vec0 virtual table with a metadata column (e.g. record_id text) and a KNN query (WHERE embedding MATCH ? AND k = 50) behaves differently depending on how you exclude rows:
- AND record_id != ? (several of these ANDed together also work) is applied inside the KNN, so you still get k results that all pass the filter.
- AND record_id NOT IN (?, ?, ...) is applied after the k nearest are chosen, so excluded rows use up result slots and you can get fewer than k results, or none.
For exclusion lists, generate ANDed != clauses (or use a partition key or metadata equality where possible) instead of NOT IN. Partition-key columns (case_id text partition key) are also applied inside the KNN, which suits per-tenant isolation. SQLite FTS5, by contrast, applies NOT IN on its UNINDEXED columns before LIMIT. Verify on your own sqlite-vec version, since filter pushdown may change between releases.