The first three posts covered reading, scoring and searching. The last one covers writing: the index writer, and a more prosaic question — how much do you actually support?
1. Writer architecture In one sentence: documents come in, get grouped by term → token, accumulate in a RAM buffer, and flush into a segment when full.
Design point Approach Why Grouping Reusable (termId, tokenIndex) integer sort Each term’s postings are written contiguously Encoding One varint stream per term: [docDelta, freq, posDelta*freq] Matches the Lucene104 format Segment names Base 36 Java’s rule; otherwise multi-segment naming collides Deleted bitmap .liv = header + bits2words(maxDoc) little-endian longs 1 = live; padding bits past maxDoc must be cleared Merge Pairwise merge tree (not whole-index reread) Bounded memory, output still equivalent to a single pass Append Pre-register source FieldInfos Preserves field numbers; otherwise they all shift 2. Acceptance: byte identity Merge and append correctness has a one-line criterion:
...