3 months ago
bcebc30The ANN query put MATCH in ORDER BY instead of WHERE and didn't use the hidden distance column for ordering. Per sqlite-vec docs, the correct KNN pattern is: WHERE embedding MATCH ? AND <metadata filters> ORDER BY distance LIMIT k The old query would error out when the vec extension is loaded, silently falling back to linear scan — defeating the ANN optimization. Under bun:sqlite the extension never loads so the bug was latent, but it would manifest on any SQLite build with extension loading support. Typecheck 8/8, tests 144 pass. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Parent7261302