Vector DB & ANN · core
Metadata Filtering
Combining vector search with structured predicates (tenant, date, tags).
Mental model
Real queries are 'nearest vectors WHERE tenant=X AND date>Y'. Pre-filtering shrinks the candidate set before ANN (accurate, can be slow); post-filtering runs ANN then drops misses (fast, can return too few). The hard part is doing it inside a graph index.
How to study Metadata Filtering
Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use Pinecone — Filtering with metadata, Weaviate — Filtered ANN search to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.
Next, compare Metadata Filtering with HNSW, RAG. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Add metadata filtering to vector search and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.
Proof of understanding
- Explain the mechanism from first principles and identify the state it reads or changes.
- Give one situation where the concept is the right choice and one where it is not.
- Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
- Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.
Where it matters
Every production vector DB; critical for multi-tenant RAG.
Common mistakes
- Post-filtering an HNSW result and returning fewer than k items
- Treating filters as an afterthought to the index design
- Ignoring multi-tenancy isolation in a shared index
Learn from primary sources
Practice and explain it back
Add metadata filtering to vector search
Extend your brute-force index to support 'nearest WHERE field = value'. Implement both pre-filtering and post-filtering and compare results and timing.
Expected evidence: Filtered top-k that always returns k items when k qualify.
Open the interactive drill →Review prompts
- Compare pre-filtering and post-filtering in vector search.
Build evidence
Metadata filtering for vector search
Add structured predicate filtering to vector search.
- Support 'nearest WHERE field = value' queries
- Implement both pre-filter and post-filter and compare
- Always return k results when k are available