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

    Fields inherited from class org.apache.lucene.index.FilterMergePolicy

    in

    Fields inherited from class org.apache.lucene.index.MergePolicy

    DEFAULT_MAX_CFS_SEGMENT_SIZE, DEFAULT_NO_CFS_RATIO, maxCFSSegmentSize, noCFSRatio
  • Constructor Summary

    Constructors
    Constructor
    Description
    ElasticsearchMergePolicy(org.apache.lucene.index.MergePolicy delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.lucene.index.MergePolicy.MergeSpecification
    findForcedMerges(org.apache.lucene.index.SegmentInfos segmentInfos, int maxSegmentCount, Map<org.apache.lucene.index.SegmentCommitInfo,Boolean> segmentsToMerge, org.apache.lucene.index.MergePolicy.MergeContext mergeContext)
     
    org.apache.lucene.index.MergePolicy
    return the wrapped merge policy
    void
    setUpgradeInProgress(boolean upgrade, boolean onlyAncientSegments)
    When upgrade is true, running a force merge will upgrade any segments written with older versions.

    Methods inherited from class org.apache.lucene.index.FilterMergePolicy

    findForcedDeletesMerges, findFullFlushMerges, findMerges, getMaxCFSSegmentSizeMB, getNoCFSRatio, keepFullyDeletedSegment, numDeletesToMerge, setMaxCFSSegmentSizeMB, setNoCFSRatio, size, toString, useCompoundFile

    Methods inherited from class org.apache.lucene.index.MergePolicy

    assertDelCount, isMerged, message, segString, verbose

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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, Map<org.apache.lucene.index.SegmentCommitInfo,Boolean> segmentsToMerge, org.apache.lucene.index.MergePolicy.MergeContext mergeContext) throws IOException
      Overrides:
      findForcedMerges in class org.apache.lucene.index.FilterMergePolicy
      Throws:
      IOException
    • setUpgradeInProgress

      public void setUpgradeInProgress(boolean upgrade, boolean onlyAncientSegments)
      When upgrade is true, running a force merge will upgrade any segments written with older versions. This will apply to the next call to IndexWriter.forceMerge(int) that is handled by this MergePolicy, as well as cascading calls made by IndexWriter.