IndexReader
One index, read at one snapshot, with every sidecar it may consult pinned for its lifetime.
This returns candidates, never answers. An index over a segment says "this segment's newest version of key K carried that value". Whether the version a caller can see still carries it is a different question, because a newer version may live in a shallower segment or in a memtable neither of which this index covers. So every hit has to be rechecked against the visible document, and uncoveredSegments has to be scanned. IndexQuery is the reference implementation of both.
An index that could return the answer would be an index that could be wrong, and the design rule it would be wrong against is the one that matters most here: an index may change query speed, never query answers.
Sidecars are pinned up front, not per term. A compaction may retire a segment at any moment, and acquiring lazily would let one disappear between the second and third term of an IN (a, b, c). The pins are released by close, which must be called — on Windows a mapped file cannot be deleted at all, so a reader left open blocks reclamation of everything it touched.
Properties
Covered, stale and total, at this snapshot. See IndexCoverage.
Whether the store held documents outside a segment when this reader pinned.
The index this reads.
Whether the candidates alone are a superset of the answer.
The path indexed.
Live segments this reader cannot answer for, which the caller must scan.
Segments this reader can answer for, ascending. The domain of every accessor below.
Functions
Ordinals carrying no value at path, taken against documentOrdinals. NOT EXISTS.
Candidate ordinals in segmentNumber whose indexed version carried term.
Candidate ordinals carrying any of terms. The IN case, unioned in one pass.
The segment's live-document universe: ordinals whose newest version there is a document.
Whether key appears in exactly one usable segment. See SegmentSelection.isUniqueKey.
The ordinals of segmentNumber whose keys lie in [from, to], both bounds inclusive.
Ordinals carrying any value at path. The EXISTS case.