Method ForceMerge
ForceMerge(Int32)
Forces merge policy to merge segments until there are <=
maxNumSegments
. The actual merges to be
executed are determined by the MergePolicy.
This is a horribly costly operation, especially when
you pass a small maxNumSegments
; usually you
should only call this if the index is static (will no
longer be changed).
Note that this requires up to 2X the index size free space in your Directory (3X if you're using compound file format). For example, if your index size is 10 MB then you need up to 20 MB free for this to complete (30 MB if you're using compound file format). Also, it's best to call Commit() afterwards, to allow IndexWriter to free up disk space.
If some but not all readers re-open while merging is underway, this will cause > 2X temporary space to be consumed as those new readers will then hold open the temporary segments at that time. It is best not to re-open readers while merging is running.
The actual temporary usage could be much less than these figures (it depends on many factors).
In general, once this completes, the total size of the index will be less than the size of the starting index. It could be quite a bit smaller (if there were many pending deletes) or just slightly smaller.
If an
This call will merge those segments present in the index when the call started. If other threads are still adding documents and flushing segments, those newly created segments will not be merged unless you call ForceMerge(Int32) again.
NOTE: if this method hits an
NOTE: if you call Dispose(Boolean)
with false
, which aborts all running merges,
then any thread still running this method might hit a
MergePolicy.MergeAbortedException.
Declaration
public virtual void ForceMerge(int maxNumSegments)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxNumSegments | maximum number of segments left in the index after merging finishes |
Exceptions
Type | Condition |
---|---|
CorruptIndexException | if the index is corrupt |
See Also
ForceMerge(Int32, Boolean)
Just like ForceMerge(Int32), except you can specify whether the call should block until all merging completes. This is only meaningful with a Lucene.Net.Index.IndexWriter.mergeScheduler that is able to run merges in background threads.
NOTE: if this method hits an
Declaration
public virtual void ForceMerge(int maxNumSegments, bool doWait)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxNumSegments | |
System.Boolean | doWait |