AlgoViz

Design Search Autocomplete (Typeahead)

medium 45 min

Suggest ten likely searches before a person finishes typing, within 100 ms, for 700,000 requests a second.

Where it shows up

The same pattern appears across everyday software.

  • Web search

    Google's help page says its predictions reflect real searches and consider the query's language, the location it comes from, trending interest and your past searches.

  • Search engines as a library

    Elasticsearch documents a completion suggester: an in-memory structure with fast lookups that is costly to build. A team that already runs it may need nothing custom.

  • Online shops

    A catalogue has perhaps a few million products. The whole index can fit inside each web server or even in the page.

  • Address forms

    Completing an address needs location-aware ranking, because the same street name exists in many towns.

  • Code editors

    The corpus is the open project, so the index lives on the developer's machine and updates as they type.

  • Contact pickers

    The list is small and private. Download it once and match on the device: no server, no delay.