Skip to content

SQLiteVecVectorStore returns fewer than limit matches for a filtered query #1790

Description

@edwinyyyu

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.

Activity

  1. added theissue type on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions