InterviewLegend

Design Search & Autocomplete

Frequently asked
Alex Chen45 min readUpdated

Someone types "wek" and before they finish the word the box already shows The Weeknd at the top, then a few of his tracks, then a playlist named after him. They never typed "weeknd" in full and they never pressed enter. That is the bar for Spotify search. Every keystroke fires a request, and results come back before the next key lands. The artist they almost certainly meant ranks above the literal-prefix matches. The corpus behind that box is large and mixed, north of a hundred million tracks, millions of artists and albums, and a fast-growing catalog of podcast shows and episodes, all sharing one search bar.

It is tempting to treat this as one inverted index and call it done, and that instinct gets you a working full-text search but a poor product. Two things break it. First, typeahead is a different access pattern from full-query search. Completing "wek" as the user types is a prefix problem, and an inverted index keyed on whole terms does not answer prefixes well. So the design carries two retrieval structures, not one. Second, ranking is where the product is won or lost. A literal-match index will surface every track with "weeknd" in its title before the artist himself, which is exactly wrong, so popularity and the listener's own history have to reorder the matches. Lead with "retrieve fast, rank by who is popular and what this listener plays," and the rest follows.

The Spotify angle
Spotify search is one box spanning four entity types and two retrieval styles at once. A candidate who builds a single text index over titles has quietly assumed the query is always a complete, correctly-spelled title. It rarely is. People type three letters, misspell artist names, and increasingly type a whole sentence describing a podcast they cannot name. Spotify published a real natural-language search system for podcast episodes precisely because term matching could not find "a podcast about starting a small business." Name the four entities and split typeahead from full search up front. This is not a generic typeahead exercise, and the design has to show it.
What's inside
  • 1 diagram
  • 5 sections
  • about 45 min

Premium lessonSpotify interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Spotify interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Spotify interview guide

Know what Spotify asks before you walk in.

11 coding · 5 system design · 23 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.