Method Commit
Commit()
Commits all pending changes (added & deleted documents, optimizations, 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 & 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.
NOTE: if this method hits an OutOfMemoryError you should immediately close the writer. See above for details.
Declaration
public void Commit()
See Also
Commit(IDictionary<String, String>)
Commits all changes to the index, specifying a commitUserData Map (String -> String). This just calls Lucene.Net.Index.IndexWriter.PrepareCommit(IDictionary{System.String,System.String}) (if you didn't already call it) and then Lucene.Net.Index.IndexWriter.FinishCommit.
NOTE: if this method hits an OutOfMemoryError you should immediately close the writer. See above for details.
Declaration
public void Commit(IDictionary<string, string> commitUserData)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.String> | commitUserData |