Suggestions are precomputed: an offline job turns query logs into tries that store the top completions at every prefix, so answering a keystroke is a single lookup. Tries are sharded by prefix, hot prefixes sit in memory and even at the CDN edge, and a stream job boosts queries that are trending right now.
Functional requirements
- Return the top 5–10 completions for the text typed so far
- Rank by popularity, freshness and (optionally) the user's history and locale
- Reflect trending queries within minutes
- Filter offensive or blocked suggestions
Non-functional requirements
- p99 under ~100 ms end to end so suggestions keep up with typing
- Very read-heavy: one request per keystroke
- Highly available; stale suggestions are acceptable, missing ones aren't
Extensions
- Personalised suggestions mixed in from the user's own history.
- Spelling correction for typos.
- Rich suggestions (entities with images) for people, places and products.