commit

open override fun commit(): Long

Commits all pending changes (added and deleted documents, segment merges, added indexes, etc.) to the index, and syncs all referenced index files, such that a reader will see the changes and the index updates will survive an OS or machine crash or power loss. Note that this does not wait for any running background merges to finish. This may be a costly operation, so you should test the cost in your application and do it only when really necessary.

Note that this operation calls Directory.sync on the index files. That call should not return until the file contents and metadata are on stable storage. For FSDirectory, this calls the OS's fsync. But, beware: some hardware devices may in fact cache writes even during fsync, and return before the bits are actually on stable storage, to give the appearance of faster performance. If you have such a device, and it does not have a battery backup (for example) then on power loss it may still lose data. Lucene cannot guarantee consistency on such devices.

If nothing was committed, because there were no pending changes, this returns -1. Otherwise, it returns the sequence number such that all indexing operations prior to this sequence will be included in the commit point, and all other operations will not.

Return

The #sequence_number of the last operation in the commit. All sequence numbers <= this value will be reflected in the commit, and all others will not.

See also

.prepareCommit