34. Design Search Autocomplete (Typeahead)
1
The interview prompt2
34.1 What do you ask first?3
34.2 How big is this, really?4
34.3 What are the doors?5
34.4 What do we store?6
34.5 What does the whole system look like?7
34.6 Trie or prefix index?8
34.7 How do you compute top-K per prefix?9
34.8 How do suggestions follow trends?10
34.9 How do you cache suggestions?11
34.10 What would you say in the last five minutes?12
Score yourself13
Variations to practise14
Sources15
Code lab34. Design Search Autocomplete (Typeahead)
34.10 What would you say in the last five minutes?
3 min read+10 XP
Step 6: Wrap-up (5 minutes)
- Bottleneck: read traffic on short prefixes. Covered by browser, CDN and in-process caching, and a sharded in-memory store.
- Single points of failure: the prefix store (replicas, and suggestions simply hide on failure); the build pipeline (the last good table keeps serving).
- Quality and safety: blocklists, minimum counts, unique-user counting, manual removal tools with fast purge.
- Next with more time: personalisation (blend in the user's own recent searches on the client), spelling correction ("dnue" → "dune"), multiple languages and scripts, and suggestions for book titles and authors as well as queries.
Memory code: "Fast because it's precomputed; fresh because it's blended; safe because it's filtered."