org.apache.lucene.index.sorter
Class SortingMergePolicy
java.lang.Object
org.apache.lucene.index.MergePolicy
org.apache.lucene.index.sorter.SortingMergePolicy
- All Implemented Interfaces:
- Closeable, 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
Sorter
s 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.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
SORTER_ID_PROP
public static final String SORTER_ID_PROP
- Put in the
diagnostics
to denote that
this segment is sorted.
- See Also:
- Constant Field Values
SortingMergePolicy
public SortingMergePolicy(MergePolicy in,
Sorter sorter)
- Create a new
MergePolicy
that sorts documents with sorter
.
isSorted
public static boolean isSorted(AtomicReader reader,
Sorter sorter)
- Returns true if the given reader is sorted by the given sorter.
findMerges
public MergePolicy.MergeSpecification findMerges(MergePolicy.MergeTrigger mergeTrigger,
SegmentInfos segmentInfos)
throws IOException
- Specified by:
findMerges
in class MergePolicy
- Throws:
IOException
findForcedMerges
public MergePolicy.MergeSpecification findForcedMerges(SegmentInfos segmentInfos,
int maxSegmentCount,
Map<SegmentCommitInfo,Boolean> segmentsToMerge)
throws IOException
- Specified by:
findForcedMerges
in class MergePolicy
- Throws:
IOException
findForcedDeletesMerges
public MergePolicy.MergeSpecification findForcedDeletesMerges(SegmentInfos segmentInfos)
throws IOException
- Specified by:
findForcedDeletesMerges
in class MergePolicy
- Throws:
IOException
clone
public MergePolicy clone()
- Overrides:
clone
in class MergePolicy
close
public void close()
- Specified by:
close
in interface Closeable
- Specified by:
close
in class MergePolicy
useCompoundFile
public boolean useCompoundFile(SegmentInfos segments,
SegmentCommitInfo newSegment)
throws IOException
- Overrides:
useCompoundFile
in class MergePolicy
- Throws:
IOException
setIndexWriter
public void setIndexWriter(IndexWriter writer)
- Overrides:
setIndexWriter
in class MergePolicy
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.