← Questions
Design keyword search over posts
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Meta's technical phone screen, last asked Oct 2025. It tests search, inverted index and feeds.
Design keyword search over posts in a large social network. Users publish short posts and status updates all the time. Others search by one or more keywords, across years of history, and see the matching posts ranked. Each user may only see posts they are allowed to see.
Requirements
- Functional: search posts by one or more keywords and return the top results, with pagination.
- Functional: new posts become searchable within seconds. Edited and deleted posts are updated or removed from results.
- Functional: results respect privacy: friends-only and public posts, and blocked users.
- Non-functional: billions of posts, hundreds of millions of new posts a day, and a very large query volume.
- Non-functional: low query latency (a few hundred milliseconds), high availability, and eventual consistency for indexing.
Clarifying questions
- Do all keywords have to match (AND), or any of them? Do we support phrases?
- Is ranking by recency, by engagement, or by relevance to the searcher?
- Which languages, and do we need stemming or typo tolerance?
- What is the read load compared with the write load?
What a strong answer covers
- The API:
search(query, cursor, limit)and the indexing path from post creation. - Build the index yourself, as an inverted index from term to posting list (post id, time, score), rather than naming an off-the-shelf engine.
- Ingestion: post events go through a queue to indexers that tokenize and update a small in-memory index, merged into larger immutable segments. Deletes are handled with tombstones.
- Sharding by post id (document partitioning, a query fans out to every shard) compared with sharding by term (hot terms overload a shard), and the decision with its reason.
- Ranking in two stages: cheap retrieval and scoring per shard, then a merge and re-rank. Recency tiers keep recent posts on fast shards.
- Privacy filtering after retrieval against the searcher's friend graph, and its cost when most matches are hidden.
- Capacity estimates for index size, write rate and query fan-out.
Follow-ups
- Add location so users can find posts near a place.
- A breaking news term suddenly appears in millions of posts and queries. What happens to the hot posting list?
- Support search over the posts of your friends only, cheaply.
- Typeahead suggestions for the search box.
Where it's asked
- Meta · Technical phone screen · Last asked Oct 202545 min · Two coding problems in CoderPad, about 20 minutes each · Usually no AI; some newer screens are AI-assisted
What it tests
search · inverted index · feeds
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing
