This one is basically 'build a mini search engine' and I went in thinking I had it covered because I knew about inverted indexes.
Start by clarifying requirements (scale, latency, consistency) and then walk through the high-level architecture: API design, indexing pipeline, ranking, and scaling. Emphasize trade-offs between freshness and relevance, and how you'd handle the constant updates.
Pro tip: Proactively discuss how you'd handle the 'cold start' problem for new posts and the 'hot' problem for viral posts, showing you understand real-world challenges beyond textbook design.
Ask about scale (DAU, QPS, post volume), latency requirements, consistency needs, and whether search is keyword-based or semantic. Define functional and non-functional requirements.
Define endpoints for search (GET /search?q=...&filters=...), with pagination, sorting, and response schema. Consider authentication, rate limiting, and error handling.
Describe how posts are ingested, processed (tokenization, stemming, etc.), and indexed. Use a message queue for asynchronous updates and a distributed search engine like Elasticsearch or a custom inverted index.
Explain ranking factors: textual relevance (TF-IDF, BM25), recency, engagement (likes, comments), and personalization. Discuss how to combine them and handle updates.
Cover sharding, replication, caching, and CDN for hot queries. Discuss trade-offs between consistency and availability, and how to handle deletions and updates efficiently.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.