How do metadata filters interact with vector search?
hardAnswer
- Two implementation strategies: (1) Pre-filter: apply metadata filter first, then vector search on the filtered subset — memory-friendly if the subset is small but breaks HNSW's graph if it fragments too many nodes.
- (2) Post-filter: retrieve top-k * expansion via vector search, then filter — simpler but may under-retrieve if filters are strict.
- Modern vector DBs (Qdrant, Weaviate, Milvus) implement hybrid strategies (filterable HNSW, bitmap pre-filtering) that maintain recall.
Check yourself — multiple choice
- Filters don't matter
- Pre-filter vs post-filter trade-off; modern vector DBs use filterable HNSW / bitmap pre-filtering to preserve recall
- Only in Elastic
- Impossible to combine
Metadata filters: pre / post / filterable HNSW — recall depends on implementation.
#vector-db#retrieval
Practise LLMs & GenAI
214 interview questions in this topic.
Related questions
- What's the trade-off between embedding dimension and retrieval quality?
- How do vector databases differ from traditional databases?
- How does HNSW work in one paragraph?
- What is IVF-PQ and when do you use it?
- How does Retrieval-Augmented Generation (RAG) work?
- What are text embeddings and how are they used?