extract

fun extract(document: Variant, sink: (pathIndex: Int, value: Variant) -> Unit)

Reports every (pathIndex, value) this document contributes.

A path may be reported more than once for one document — $.tags[*] over three tags reports three values — and a duplicate reports the same value twice. Both are correct: an inverted index's posting list is a set of ordinals, and a column stores one slot per occurrence.

The raw Variant is reported, not a term, so that one walk serves both index kinds. An inverted index turns it into a ValueSignature; a column turns it into a ColumnValue. This is what makes "the recheck runs the same walk that built the index" true of both — a second, differently-shaped traversal would be a second definition of what a path means, and the two would eventually disagree about an array or a nested null.

A JSON null is reported like any other value. It is present, which is what makes EXISTS exact: a document with {"note": null} has a note.

The value is a view over bytes valid only for the duration of the call; anything kept must be copied.