Overload List
Name | Description | |
---|---|---|
Close()()()() | Commits all changes to an index and closes all
associated files. Note that this may be a costly
operation, so, try to re-use a single writer instead of
closing and opening a new one. See {@link #Commit()} for
caveats about write caching done by some IO devices.
If an Exception is hit during close, eg due to disk
full or some other reason, then both the on-disk index
and the internal state of the IndexWriter instance will
be consistent. However, the close will not be complete
even though part of it (flushing buffered documents)
may have succeeded, so the write lock will still be
held. If you can correct the underlying cause (eg free up
some disk space) then you can call close() again.
Failing that, if you want to force the write lock to be
released (dangerous, because you may then lose buffered
docs in the IndexWriter instance) then you can do
something like this: try { writer.close(); } finally { if (IndexWriter.isLocked(directory)) { IndexWriter.unlock(directory); } }after which, you must be certain not to use the writer instance anymore.NOTE: if this method hits an OutOfMemoryError you should immediately close the writer, again. See above for details. | |
Close(Boolean) | Closes the index with or without waiting for currently
running merges to finish. This is only meaningful when
using a MergeScheduler that runs merges in background
threads.
NOTE: if this method hits an OutOfMemoryError
you should immediately close the writer, again. See above for details.NOTE: it is dangerous to always call
close(false), especially when IndexWriter is not open
for very long, because this can result in "merge
starvation" whereby long merges will never have a
chance to finish. This will cause too many segments in
your index over time. |