Design post search (like searching posts on Facebook or X)
A user types "solar eclipse" and gets the posts that mention it, the best or the newest first, including one posted ten seconds ago, and never one she isn't allowed to see. It's a librarian who can find any letter in the archive by its words but checks the visitors' book before handing one over.
It's also asked as "design Twitter search" or "search for a social network". The move behind it is taught in Adding search to a product, the engine in Search engines and inverted indexes. Interviewers like it because the index grows forever while most searches want this week, and because every result must respect audiences, blocks and deletions. This page runs the photo app from earlier pages, and its closest case study is Search autocomplete, which suggests the query before this page answers it.
Below is a full mock interview following the seven steps of the framework. You're the candidate: at each Guess before you read on, stop and answer first.
Step 1 · Clarify the features and cut the scope
Minutes 0–5 · How this step works
Interviewer: Design search over posts for our photo app.
You: A few questions first. What's searched: captions and hashtags, or also people and the photos themselves?
Interviewer: Captions and hashtags. People search is another team's.
You: Whose posts can come back? Posts have audiences: public, followers, close friends, only me.
Interviewer: Anything the searcher may see. Blocks apply too.
You: How fresh must it be? And in what order?
Interviewer: A new post within seconds, since during news people search for what just happened. Two tabs, Top and Latest, as X has them in 2026.
You: How far back?
Interviewer: Every post ever, though most searches want this week.
You: Then I'll cover caption and hashtag search over every post, Top and Latest tabs, a date filter, audiences and blocks, and deleted posts disappearing. Out: people search, searching photos by what's in them, suggestions as you type, ads and personal ranking beyond a boost for accounts you follow. OK?
Interviewer: Good.
Each answer shapes the design: captions mean an inverted index fed from the posts database, and audiences mean a filter per searcher inside the index. "Within seconds" means a change stream with a one-second refresh, and "most want this week" means the index is split by time.