Build a distributed search engine (Elasticsearch / OpenSearch style)

About Build a distributed search engine (Elasticsearch / OpenSearch style)

Five million books, a search box, and a 100 ms budget. Build the engine from the inverted index up — segment, refresh, shard, replica, scatter-gather, BM25 — and feel why every guarantee that lives across shards is paid for in either an extra round trip or a small lie about the rankings.

Difficulty
beginner
Time
about 80 minutes
Stages
9
Topic
Search, Indexing & Retrieval

How this problem is worked

Nine stages, from what the thing is for to how it compares with the real implementations. Each asks one question, and the simulator runs the architecture you draw against the requirements you wrote.

  1. 01Purpose & invariantsWhat is this for, and what must always be true of it?
  2. 02Workload characterizationWho writes, who reads, and in what shapes?
  3. 03Data model & on-disk formatWhat does the data look like at rest?
  4. 04Core algorithmsHow do the write path and the read path actually work?
  5. 05Distribution & replicationHow does this scale out and survive losing a machine?
  6. 06Consistency & correctnessUnder concurrency and failure, what is guaranteed?
  7. 07Failure modes & recoveryWhat actually happens when each part fails?
  8. 08Operational characteristicsCan a human run this at three in the morning?
  9. 09Trade-offs & comparisonWhere does this sit against the alternatives?

Primary sources for this problem

  • Elasticsearch Reference — Index modules, Mapping, Indexing, Search, Aggregations
  • Elasticsearch — Near real-time search (refresh / flush / translog vocabulary)
  • Lucene — segment file format documentation
  • Robertson & Zaragoza — The Probabilistic Relevance Framework: BM25 and Beyond
  • Elastic blog — BM25: The Next Generation of Lucene Relevance and the Practical BM25 series
  • Kleppmann — Designing Data-Intensive Applications, Chapter 3 (storage & retrieval)

Browse the full problem catalog, or see what the simulator does and does not model.