Package org.elasticsearch.index.shard
Class ElasticsearchMergePolicy
java.lang.Object
org.apache.lucene.index.MergePolicy
org.apache.lucene.index.FilterMergePolicy
org.elasticsearch.index.shard.ElasticsearchMergePolicy
public final class ElasticsearchMergePolicy
extends org.apache.lucene.index.FilterMergePolicy
A
MergePolicy that upgrades segments and can upgrade merges.
It can be useful to use the background merging process to upgrade segments, for example when we perform internal changes that imply different index options or when a user modifies his mapping in non-breaking ways: we could imagine using this merge policy to be able to add doc values to fields after the fact or on the opposite to remove them.
For now, this MergePolicy takes care of moving versions that used to
be stored as payloads to numeric doc values.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.MergePolicy
org.apache.lucene.index.MergePolicy.MergeAbortedException, org.apache.lucene.index.MergePolicy.MergeContext, org.apache.lucene.index.MergePolicy.MergeException, org.apache.lucene.index.MergePolicy.MergeSpecification, org.apache.lucene.index.MergePolicy.OneMerge, org.apache.lucene.index.MergePolicy.OneMergeProgress -
Field Summary
-
Constructor Summary
Constructors Constructor Description ElasticsearchMergePolicy(org.apache.lucene.index.MergePolicy delegate) -
Method Summary
Modifier and Type Method Description org.apache.lucene.index.MergePolicy.MergeSpecificationfindForcedMerges(org.apache.lucene.index.SegmentInfos segmentInfos, int maxSegmentCount, java.util.Map<org.apache.lucene.index.SegmentCommitInfo,java.lang.Boolean> segmentsToMerge, org.apache.lucene.index.MergePolicy.MergeContext mergeContext)org.apache.lucene.index.MergePolicygetDelegate()return the wrapped merge policyvoidsetUpgradeInProgress(boolean upgrade, boolean onlyAncientSegments)Whenupgradeis true, running a force merge will upgrade any segments written with older versions.Methods inherited from class org.apache.lucene.index.FilterMergePolicy
findForcedDeletesMerges, findMerges, getMaxCFSSegmentSizeMB, getNoCFSRatio, keepFullyDeletedSegment, numDeletesToMerge, setMaxCFSSegmentSizeMB, setNoCFSRatio, size, toString, useCompoundFile
-
Constructor Details
-
ElasticsearchMergePolicy
public ElasticsearchMergePolicy(org.apache.lucene.index.MergePolicy delegate)- Parameters:
delegate- the merge policy to wrap
-
-
Method Details
-
getDelegate
public org.apache.lucene.index.MergePolicy getDelegate()return the wrapped merge policy -
findForcedMerges
public org.apache.lucene.index.MergePolicy.MergeSpecification findForcedMerges(org.apache.lucene.index.SegmentInfos segmentInfos, int maxSegmentCount, java.util.Map<org.apache.lucene.index.SegmentCommitInfo,java.lang.Boolean> segmentsToMerge, org.apache.lucene.index.MergePolicy.MergeContext mergeContext) throws java.io.IOException- Overrides:
findForcedMergesin classorg.apache.lucene.index.FilterMergePolicy- Throws:
java.io.IOException
-
setUpgradeInProgress
public void setUpgradeInProgress(boolean upgrade, boolean onlyAncientSegments)Whenupgradeis true, running a force merge will upgrade any segments written with older versions. This will apply to the next call toIndexWriter.forceMerge(int)that is handled by thisMergePolicy, as well as cascading calls made byIndexWriter.
-