Design a full-text search engine similar to Elasticsearch that indexes and searches a corpus of 10 billion documents (web pages, articles, product listings). The system supports complex boolean queries (AND, OR, NOT), phrase matching ("exact phrase"), field-specific search (title:query), and relevance ranking. It handles 50,000 search queries per second and must index new documents within 5 seconds of ingestion.
In your 90-second answer, cover: - Core data structure for full-text search and how documents are indexed - Query processing: how boolean operators and phrase matching are evaluated - Relevance ranking algorithm and what signals it uses - How you achieve near-real-time indexing (new documents searchable within seconds)
Constraints: search latency must be under 200ms at p99. The system must handle documents ranging from 1 KB to 10 MB. Index size is approximately 30% of raw document size.
How to approach it
- Hint 1
The inverted index is the foundational data structure: for each term in the corpus, store a sorted list of document IDs (posting list) where that term appears, along with term frequency and position information. Boolean queries become set operations on posting lists.
- Hint 2
For phrase matching, you need positional information in the posting list -- not just which documents contain the terms, but where in the document each term appears. Phrase queries check that terms appear at consecutive positions.
- Hint 3
Near-real-time indexing uses a dual-buffer approach: new documents are written to a small in-memory index segment (mutable), while the main index segments are immutable on disk. Periodically, the in-memory segment is flushed and merged with disk segments. Searches query both.
Ready to answer it out loud?
Record your answer in 1:30 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.
Practising needs an invite code. Join the waitlist and we’ll send you one.