Class SortingMergePolicy

java.lang.Object
org.apache.lucene.index.MergePolicy
org.apache.lucene.index.sorter.SortingMergePolicy
All Implemented Interfaces:
Closeable, AutoCloseable, Cloneable

public final class SortingMergePolicy extends MergePolicy
A MergePolicy that reorders documents according to a Sorter before merging them. As a consequence, all segments resulting from a merge will be sorted while segments resulting from a flush will be in the order in which documents have been added.

NOTE: Never use this MergePolicy if you rely on IndexWriter.addDocuments(Iterable, org.apache.lucene.analysis.Analyzer) to have sequentially-assigned doc IDs, this policy will scatter doc IDs.

NOTE: This MergePolicy should only be used with idempotent Sorters so that the order of segments is predictable. For example, using SortingMergePolicy with Sorter.REVERSE_DOCS (which is not idempotent) will make the order of documents in a segment depend on the number of times the segment has been merged.