Skip to content

Metadata Filtering

Restricting vector search results using structured scalar attributes alongside semantic similarity, combining exact conditions with approximate search.

Metadata filtering restricts vector search results using structured attributes stored alongside each vector — fields like category, date, author, price, language, or status. It combines the fuzzy power of semantic similarity with the precision of exact conditions, so a query can ask for the most similar items that also meet specific criteria.

This capability is what makes vector search practical for real applications, where pure similarity is rarely sufficient. A search might want documents similar to a query but only within a chosen topic and published recently, or products visually like an image but only those in stock and under a price. The vector handles the similarity; the metadata filter enforces the hard rules.

How the filter is applied matters greatly. Pre-filtering narrows the candidate set before searching, post-filtering removes non-matching results afterward, and in-graph filtering applies conditions during traversal — each with different effects on speed and recall. Doing this well, especially for selective or high-cardinality filters, is a hallmark of a mature vector database, since naive filtering can cause slow queries or the recall cliff.