AlgoViz

Indexing in distributed search

medium 28 min

How documents become a searchable index spread over many machines: the analysis chain, posting lists and their compression, segments and merges, and the choice between splitting by document or by term.

Where it shows up

The same pattern appears across everyday software.

  • Elasticsearch

    Each shard is a Lucene index. Refresh is every second by default for indices that are being searched, and an index has one primary shard unless you say otherwise.

  • Lucene

    Segments are immutable. Deleted documents keep their number until a merge, when the remaining ones get new numbers.

  • Google and Percolator

    The paper describes replacing a batch indexing system with one that processes each crawled document as a small transaction.

  • Shop catalogue

    Prices change often, names rarely. Keeping price outside the text index, or updating in small bulks, avoids rewriting whole documents for each price.

  • Logs

    Written once, never updated. One index for each day makes deletion cheap: drop the whole index instead of marking documents.

  • Mail search

    Every query is for one mailbox. Routing by mailbox puts its documents on one shard, so a search asks one shard and not all.