Skip to main content
InterviewHubPRO
Section Overview
Q48

Question 48 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

96%
Vector DBs & RAG (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Filtering Strategies: Pre-Filtering vs Post-Filtering vs Single-Stage Filtered Vector Search.

senior LevelMost Askedvector-databasesAdvanced Internals

In Simple Words: Query: "Find matching vectors where category == 'medical' and year >= 2023":

  • Post-Filtering: Runs ANN vector search first, retrieves top 100 results, then filters out non-medical documents. Major Flaw: If only 2% of the database is medical, all 100 results might get filtered out, returning 0 matches!
  • Pre-Filtering: Filters documents first, then runs brute-force vector search over the filtered set. Slow if the filtered set contains millions of records.
  • Single-Stage Filtered Search (Qdrant / Milvus): Traverses the HNSW graph while checking a bitset/payload index during every graph traversal hop. Guarantees top $K$ results matching all metadata filters with zero missing matches.