Why architecture matters here
Search fails on relevance more often than on speed. A fast engine that returns the wrong result loses users. A slow engine that returns the right one loses users. The architecture matters because different failures have different fixes — retrieval failures are indexing issues; ranking failures are feature and model issues; personalization failures are data issues.
Getting the layers right lets each team optimize independently: indexers focus on freshness; ranker teams on NDCG; SRE on latency and cache hit rate.
With the architecture in your head you can grow search organically instead of rewriting every year.
The architecture: every piece explained
The top strip is the retrieval half. Documents flow into the pipeline. Indexer builds inverted indexes and shards them across nodes. Retrieval combines lexical (BM25) and vector (dense embeddings) search to produce candidate documents. Ranker is a learned model that scores candidates using features from query, document, and context.
The middle row is the query understanding. Query pipeline parses, expands, and corrects spelling. Relevance ML trains the ranker with click and label data. Result cache serves popular queries from memory with prewarming. Typeahead suggests completions using prefix trees and n-gram models.
The bottom rows are usage and ops. Personalization layers user features into ranking. Observability tracks NDCG, click-through rate, latency percentiles. Ops handles index rebuilds, shard rebalancing, and A/B testing for relevance changes.
End-to-end flow
End-to-end: a user types "red running shoes size 10". Typeahead suggests "red running shoes size 10 mens". The user clicks a suggestion. Query pipeline parses attributes (color=red, category=running_shoes, size=10, gender=mens). Retrieval combines BM25 on tokens with vector search on product embeddings to produce 500 candidates. Ranker scores candidates using features (relevance to query, personal preference, price, availability). Top 20 return in 45 ms. User clicks the third result; the click flows into the relevance ML feedback loop. Observability shows NDCG@10 stable at 0.82; latency p95 at 78 ms.