BPReorderingMergePolicy (Lucene 10.5.1 misc API)
Description: declaration: package: org.apache.lucene.misc.index, class: BPReorderingMergePolicy

Package org.apache.lucene.misc.index

# Class BPReorderingMergePolicy

java.lang.Object
org.apache.lucene.index.MergePolicy
org.apache.lucene.index.FilterMergePolicy
org.apache.lucene.misc.index.BPReorderingMergePolicy

All Implemented Interfaces:
  `Unwrappable<MergePolicy>`

public final class BPReorderingMergePolicy extends FilterMergePolicy
A merge policy that reorders merged segments according to a `BPIndexReorderer`. When reordering doesn't have enough RAM, it simply skips reordering in order not to fail the merge. So make sure to give enough RAM to your `BPIndexReorderer` via `BPIndexReorderer.setRAMBudgetMB(double)`.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.lucene.index.MergePolicy

  `MergePolicy.MergeAbortedException, MergePolicy.MergeContext, MergePolicy.MergeException, MergePolicy.MergeObserver, MergePolicy.MergeSpecification, MergePolicy.OneMerge, 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
  `BPReorderingMergePolicy(MergePolicy in, BPIndexReorderer reorderer)`
  Sole constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MergePolicy.MergeSpecification`
  `findForcedDeletesMerges(SegmentInfos segmentInfos, MergePolicy.MergeContext mergeContext)`
  `MergePolicy.MergeSpecification`
  `findForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, Map<SegmentCommitInfo,Boolean> segmentsToMerge, MergePolicy.MergeContext mergeContext)`
  `MergePolicy.MergeSpecification`
  `findFullFlushMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos, MergePolicy.MergeContext mergeContext)`
  `MergePolicy.MergeSpecification`
  `findMerges(CodecReader... readers)`
  `MergePolicy.MergeSpecification`
  `findMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos, MergePolicy.MergeContext mergeContext)`
  `void`
  `setMinNaturalMergeNumDocs(int minNaturalMergeNumDocs)`
  Set the minimum number of docs that a merge must have for the resulting segment to be reordered.
  `void`
  `setMinNaturalMergeRatioFromBiggestSegment(float minNaturalMergeRatioFromBiggestSegment)`
  Set the minimum number of docs that a merge must have for the resulting segment to be reordered, as a ratio of the total number of documents of the current biggest segment in the index.

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

  `getMaxCFSSegmentSizeMB, getNoCFSRatio, keepFullyDeletedSegment, maxFullFlushMergeSize, numDeletesToMerge, setMaxCFSSegmentSizeMB, setNoCFSRatio, size, toString, unwrap, 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

  - ### BPReorderingMergePolicy

    public BPReorderingMergePolicy(MergePolicy in, BPIndexReorderer reorderer)
    Sole constructor. It takes the merge policy that should be used to compute merges, and will then reorder doc IDs from all merges above the configured minimum doc count, as well as all forced merges.

    If you wish to only run reordering upon forced merges, pass `Integer.MAX_VALUE` as a `minNaturalMergeNumDocs`. Otherwise a default value of `2^18 = 262,144` is suggested. This should help retain merging optimizations on small merges while reordering the larger segments that are important for good search performance.

    Parameters:
      `in` - the merge policy to use to compute merges
      `reorderer` - the `BPIndexReorderer` to use to renumber doc IDs

- ## Method Details

  - ### setMinNaturalMergeNumDocs

    public void setMinNaturalMergeNumDocs(int minNaturalMergeNumDocs)
    Set the minimum number of docs that a merge must have for the resulting segment to be reordered.

  - ### setMinNaturalMergeRatioFromBiggestSegment

    public void setMinNaturalMergeRatioFromBiggestSegment(float minNaturalMergeRatioFromBiggestSegment)
    Set the minimum number of docs that a merge must have for the resulting segment to be reordered, as a ratio of the total number of documents of the current biggest segment in the index. This parameter helps only enable reordering on segments that are large enough that they will significantly contribute to overall search performance.

  - ### findMerges

    public MergePolicy.MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos, MergePolicy.MergeContext mergeContext) throws IOException
    Overrides:
      `findMerges` in class `FilterMergePolicy`
    Throws:
      `IOException`

  - ### findForcedMerges

    public MergePolicy.MergeSpecification findForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, Map<SegmentCommitInfo,Boolean> segmentsToMerge, MergePolicy.MergeContext mergeContext) throws IOException
    Overrides:
      `findForcedMerges` in class `FilterMergePolicy`
    Throws:
      `IOException`

  - ### findForcedDeletesMerges

    public MergePolicy.MergeSpecification findForcedDeletesMerges(SegmentInfos segmentInfos, MergePolicy.MergeContext mergeContext) throws IOException
    Overrides:
      `findForcedDeletesMerges` in class `FilterMergePolicy`
    Throws:
      `IOException`

  - ### findFullFlushMerges

    public MergePolicy.MergeSpecification findFullFlushMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos, MergePolicy.MergeContext mergeContext) throws IOException
    Overrides:
      `findFullFlushMerges` in class `FilterMergePolicy`
    Throws:
      `IOException`

  - ### findMerges

    public MergePolicy.MergeSpecification findMerges(CodecReader... readers) throws IOException
    Overrides:
      `findMerges` in class `FilterMergePolicy`
    Throws:
      `IOException`