## org.apache.lucene.index
Class MergePolicy

    java.lang.Object
      org.apache.lucene.index.MergePolicy

Direct Known Subclasses:
  LogMergePolicy

    public abstract class MergePolicy

extends Object

Expert: a MergePolicy determines the sequence of primitive merge operations to be used for overall merge and optimize operations.

Whenever the segments in an index have been altered by `IndexWriter`, either the addition of a newly flushed segment, addition of many segments from addIndexes* calls, or a previous merge that may now need to cascade, `IndexWriter` invokes `findMerges(org.apache.lucene.index.SegmentInfos, org.apache.lucene.index.IndexWriter)` to give the MergePolicy a chance to pick merges that are now required. This method returns a `MergePolicy.MergeSpecification` instance describing the set of merges that should be done, or null if no merges are necessary. When IndexWriter.optimize is called, it calls `findMergesForOptimize(org.apache.lucene.index.SegmentInfos, org.apache.lucene.index.IndexWriter, int, java.util.Set)` and the MergePolicy should then return the necessary merges.

Note that the policy can return more than one merge at a time. In this case, if the writer is using `SerialMergeScheduler`, the merges will be run sequentially but if it is using `ConcurrentMergeScheduler` they will be run concurrently.

The default MergePolicy is `LogByteSizeMergePolicy`.

NOTE: This API is new and still experimental (subject to change suddenly in the next release)

Nested Class Summary
`static class` `MergePolicy.MergeAbortedException`
`static class` `MergePolicy.MergeException` Exception thrown if there are any problems while executing a merge.
`static class` `MergePolicy.MergeSpecification` A MergeSpecification instance provides the information necessary to perform multiple merges.
`static class` `MergePolicy.OneMerge` OneMerge provides the information necessary to perform an individual primitive merge operation, resulting in a single new segment.

Constructor Summary
`MergePolicy()`

Method Summary

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MergePolicy

    public MergePolicy()

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.