Step 1: Understand the problem and establish a scope

Questions:

  1. From which part of the query does the matching start, the start or the middle part?
    1. It should begin from the start of the query.
  2. How many suggestions for autocomplete should be shown?
    1. 5
  3. How to know which suggestion to show?
    1. Depending on the search frequency of the query.
  4. Is English the only supported language?
    1. Yes.
  5. Are we considering Uppercase and special characters in the query?
    1. No, only lowercase English letters.
  6. How many users are using the product?
    1. 10 mil DAU

Auto-suggestions should be fast enough, as Facebook suggests in their articles, a response should be shown within 100 ms. The results should be relevant to the search query and sorted by some criteria, such as frequency, popularity, or other ranking systems.

Back-of-the-envelope estimation


Step 2: High-level design