A product catalog RAG system stores items with metadata: category (string), price (float), in_stock (boolean), and release_date (ISO date). A user query is 'Show me affordable in-stock cameras released this year.' The retrieval pipeline currently embeds the full query and performs ANN search. Results include expensive cameras, out-of-stock cameras, and cameras from prior years. What is the most effective retrieval architecture?
Select an answer to reveal the explanation.
Short Explanation
Here's the deal — you should pre-filter hard metadata constraints before ANN search. That way the ANN only scores eligible in-stock, current-year cameras, and the top results are guaranteed to satisfy those constraints. Then semantic ranking handles the 'affordable cameras' relevance.
Full Explanation
Pre-filtering with hard metadata constraints (in_stock=true, release_date within current year) before ANN search is the appropriate pattern when filter conditions are hard constraints that a matching result must satisfy. Applying these as pre-filters ensures the ANN search only scores documents that are eligible, so the top-k results are guaranteed to satisfy the constraints. The semantic component then ranks eligible items by relevance to 'cameras' and implicit affordability signals. Post-filtering metadata after ANN retrieval and re-ranking by price ascending is wrong because it risks dropping below a useful number of results when the filtered-out fraction is large; if only 5% of products are in-stock 2026 cameras, top-20 ANN retrieval may return only 1 qualifying result. Embedding metadata fields numerically into the product embedding vector is wrong because it causes the embedding model to conflate price proximity with semantic similarity, degrading the model's ability to distinguish between product categories; metadata and semantics should be handled separately. Using keyword search for the category term 'cameras' and applying metadata filters while completely replacing semantic embedding search is wrong because pure keyword search misses synonyms and category variants; hybrid retrieval combining both is superior to replacing semantic search entirely.