Skip to main content

Design semantic search for an online store with 10 million products. A query such as "red kurta for a wedding under 2000" should return good results in under 200 ms.

System design · Pro 1

Short answer

Clarify the metric, latency and query types. Parse the query into filters such as price and colour plus plain text. Run hybrid search, keyword and vector together, with metadata filters, then rerank the top results with relevance and business signals. Keep the index fresh for price and stock, evaluate offline with labelled queries, then A/B test.

Deeper answer

Requirements: what success means (clicks, add to cart, purchases), the latency target, languages and spelling variety, and how fast price and stock change. Exact queries such as a model number must still work, so keyword search stays.

Design: at index time, embed each product's title, description and attributes, and store structured fields such as price, colour, category and stock. At query time, extract filters: "under 2000" becomes a price filter and "red" a colour. Then run keyword search and approximate nearest-neighbour vector search, merge the two lists, and apply the filters. A reranker scores the top 100 or so with query relevance plus signals such as popularity, rating and availability.

Trade-offs: a cross-encoder reranker improves relevance but costs latency, so rerank a small set and keep a strict time budget. A language model call per query is too slow and costly at this scale, so use it offline or only for rare queries. Filtered vector search can slow down or lose recall with very selective filters. Measure NDCG and recall on labelled queries, then confirm with an A/B test on conversion. Watch queries with zero results.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Hybrid search, reranking and filters

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.