createIndexInBackground

Defines an index and builds it on the catalog's own thread, returning at once.

val build = indexes.createIndexInBackground(store, IndexDefinition.inverted("$.team"))
// queries work immediately, scanning what the index does not cover yet
build.await()

The returned IndexBuild.handle is usable straight away, for the reason createIndex documents: the definition is made durable before a single posting file exists, so there is a registered index before there is anything to build it from. Coverage grows from none to complete with no cutover, which is what per-segment sidecars have always allowed and what a blocking build was simply never able to expose.

Unlike createIndex, this runs a pass even when the definition already exists, and the difference is the whole of the resumption story. A build that was cancelled, or that a crash cut short, leaves an index defined and partly covered; calling this again with the same definition skips every segment already covered — beginSegment answers null for those without reading them — and finishes the rest. There is no separate "resume" verb because there is no separate state to resume from.

Documents still in a memtable are not indexed, exactly as for createIndex; call DocumentStore.flush first if complete coverage is wanted.