Distributed Search Engine (Elasticsearch) 00:00:01 A newly listed pair of headphones cannot be found yet A marketplace accepts an updated product listing and immediately searches for it. This illustrative search engine distinguishes a write's replication path from the refresh that makes analyzed text searchable. An indexer sends listing 123, version 41, to a coordinator. Its site and ID choose one shard. The primary orders writes for that shard. Analyze the text into indexed terms and record the write under the shard's durability policy. Every current in-sync copy receives the operation. All must reply, or a failed copy leaves the set first. A refresh exposes the new searchable segment. The refresh schedule is a setting with both freshness and indexing costs. A durable write is not necessarily visible to a new search instantly. Declare the required freshness contract and measure it from acknowledgement to successful retrieval using an actual product query. 00:00:56 Find documents containing both words Before distributing the search, inspect one shard. It maintains posting lists of document identifiers for terms. A query requiring two words can intersect the sorted lists instead of scanning every product description. Wireless points to documents 1, 5, 12 and 15. Headphones points to 2, 5 and 15. Advance through both sorted lists and keep only identifiers that occur in both. The intersection identifies candidates satisfying the term condition. It does not finish ranking, authorization or availability filtering. Keep those steps distinct when explaining why a product did or did not appear. 00:01:35 The coordinator asks for candidates, then for documents A user requests ten headphone products. The coordinating service needs evidence from each relevant shard, but fetching full text for every candidate would waste network and storage work. The coordinator checks the query, permission and limits. Word queries, exact filters, ranges and fuzzy parts become a plan. Choose one good copy of each shard in this site and ask them all. Read postings in every segment, intersect them, apply filters and keep the local best ten with BM25 scores. Merge the shard candidates into the requested order before fetching the selected documents. Get only ten documents, build highlights, and answer. A missing shard sets partial. Ask shards for scored candidates, merge according to the configured ranking semantics, and fetch only the winners. A failure policy must say whether an incomplete shard set yields a labeled partial answer or a failed search. 00:02:31 Page two must refer to the same search world As the user scrolls, products continue to update. Offset pagination against a changing result order can skip or repeat an item. A point-in-time view plus a stable sort cursor offers a different contract. The client asks for a view that lives one minute. Each shard keeps the segments of this view. Merged replacements may appear, but the old files cannot leave yet. Sort by score and unique ID, merge 1,000 results and remember the last values. Continue from the previous page's sort values against the same retained view. Close the view or let it expire. Merges can now remove its old files. Keep the tie-breaker deterministic, carry the last sort values, and close or expire the point-in-time view. Pinned segments use storage and resources, so unlimited scrolling sessions have an operational price. 00:03:24 One slow shard holds up ninety-nine fast answers A wide query reaches a hundred shards. Ninety-nine replies do not finish an exact global result if the final shard might contain the best document. Compare waiting, selecting a replica and reporting partial results. A wide query includes one busy copy. Within a 5% extra-request budget, ask another copy after a short delay and use the first reply. If neither answers, return the other 99 with partial true. A caller that needs completeness may fail instead. A bounded hedged request can help a transient straggler while increasing load. Enforce the deadline and extra-request budget. Search quality, completeness, freshness and latency are separate outcomes for the same shopper.