createIndex

Defines an index and builds it over everything already written.

Returns the existing handle if this store already has an index over the same path and kind: creating a second copy of one is a mistake rather than an intent, and giving it a new id would double the sidecars silently.

The definition is made durable before a single posting file exists, and that order is the whole of the crash story. A crash here leaves an index that is defined and uncovered, which is a state every query already handles by scanning. The other order would leave posting files for an index nothing knows about — files nothing would ever read and nothing would ever delete.

Runs the build on the calling thread. Documents still in a memtable are not indexed; call DocumentStore.flush first if complete coverage is wanted immediately.