Lucene's Search Execution: impacts, WAND and MAXSCORE

The previous post covered the performance fight. This one goes inside the executor: how a query runs from Weight to Scorer to DocIdSetIterator, and what impacts, WAND and MAXSCORE each solve. 1. The execution skeleton Lucene executes a query as a tree: Query → Weight (reusable scoring logic) → Scorer (one per segment) → DocIdSetIterator (iterate docs) + score function Weight: segment-independent “how to score”; Scorer: segment-specific “which docs to score”; DISI: only nextDoc() / advance(doc). The naive execution: walk each clause’s postings, intersect/union, score each doc. Slow but correct. ...

October 20, 2026 · 3 min · daviszhen

Writing a Search Engine from Scratch: Rewriting Lucene in C++

A search engine looks like “inverted index plus TF-IDF” — until you try to make it agree with Lucene bit for bit. This series records an attempt to rewrite Lucene 10.4 in C++. Not a toy: Java must be able to read a C++-written index (CheckIndex OK), the same queries must return the same documents and the same score bits, and performance must land in the same ballpark. 1. Why rewrite The point isn’t reinventing a wheel. It’s three things: ...

October 20, 2026 · 3 min · daviszhen

Rewriting Lucene in C++ (Part 3): From 128 to 592 QPS — The Search Performance Fight

The first two posts were about “is it right.” This one is about “is it fast” — and not a 10% difference, but 5x. 1. Baseline: 128 vs 634 QPS 1M docs, luceneutil task set, Top-10: Scale C++ Java 250K docs 483 QPS 1,886 QPS 1M docs 128 QPS 634 QPS The gap isn’t constant — it grows with data size, which means the bottleneck is the per-document processing path, not startup overhead. ...

October 20, 2026 · 4 min · daviszhen