Design Search & Autocomplete
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.
- 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
Spotify interview guideKnow what Spotify asks before you walk in.
11 coding · 5 system design · 23 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.