Search Autocomplete / Typeahead
mediumOpen designVery commonly asked~45 minHLD roundPhone screenSDE-2 and upGoogleAmazonFlipkartMicrosoftSwiggyMetaSearch & IndexingCachingStorage & Data ModellingStreaming & Real-time Data
The question, as asked
“Design the suggestion dropdown under our search box. It should feel instant, and it should suggest what people are actually searching for right now.”
Scope it before you design it
The prompt is vague on purpose. These are the clarifying questions a strong candidate asks first — answer them out loud before you touch the architecture.
- What's 'instant'? Pin it to a number — under 100ms including network, or the dropdown lags behind typing and people stop looking at it.
- Suggest from what: historical query logs, the product catalogue, or the user's own past searches? Each is a different data source and a different index.
- How fresh? If a trending query must appear within minutes, you need a streaming update path. If daily is fine, a nightly build is dramatically simpler.
- Personalised or global? Personalisation means you can't serve one cached answer per prefix, which changes the caching story completely.
- Scale: queries per second on the suggest endpoint — remember it's several per search, one per keystroke — and the number of distinct queries in the corpus.
- Typo tolerance in scope? 'bangalre' should still suggest Bangalore. Fuzzy matching is a materially harder index than prefix matching, so get it stated rather than assumed.
Your answer, first
Commit something before anything unlocks. Saved on this device as you go.
0 charactersExpand for room to draw
Framework hint
Sketch or write your approach above first. The hint gives you the structure, not the answer.