Package org.apache.lucene.index
Class SoftDeletesRetentionMergePolicy
- java.lang.Object
-
- org.apache.lucene.index.MergePolicy
-
- org.apache.lucene.index.FilterMergePolicy
-
- org.apache.lucene.index.OneMergeWrappingMergePolicy
-
- org.apache.lucene.index.SoftDeletesRetentionMergePolicy
-
- All Implemented Interfaces:
Unwrappable<MergePolicy>
public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMergePolicy
ThisMergePolicy
allows to carry over soft deleted documents across merges. The policy wraps the merge reader and marks documents as "live" that have a value in the soft delete field and match the provided query. This allows for instance to keep documents alive based on time or any other constraint in the index. The main purpose for this merge policy is to implement retention policies for document modification to vanish in the index. Using this merge policy allows to control when soft deletes are claimed by merges.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.MergePolicy
MergePolicy.MergeAbortedException, MergePolicy.MergeContext, MergePolicy.MergeException, 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 SoftDeletesRetentionMergePolicy(String field, Supplier<Query> retentionQuerySupplier, MergePolicy in)
Creates a newSoftDeletesRetentionMergePolicy
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier)
Returns true if the segment represented by the given CodecReader should be keep even if it's fully deleted.int
numDeletesToMerge(SegmentCommitInfo info, int delCount, IOSupplier<CodecReader> readerSupplier)
Returns the number of deletes that a merge would claim on the given segment.-
Methods inherited from class org.apache.lucene.index.OneMergeWrappingMergePolicy
findForcedDeletesMerges, findForcedMerges, findFullFlushMerges, findMerges
-
Methods inherited from class org.apache.lucene.index.FilterMergePolicy
findMerges, getMaxCFSSegmentSizeMB, getNoCFSRatio, maxFullFlushMergeSize, setMaxCFSSegmentSizeMB, setNoCFSRatio, size, toString, unwrap, useCompoundFile
-
Methods inherited from class org.apache.lucene.index.MergePolicy
assertDelCount, isMerged, message, segString, verbose
-
-
-
-
Constructor Detail
-
SoftDeletesRetentionMergePolicy
public SoftDeletesRetentionMergePolicy(String field, Supplier<Query> retentionQuerySupplier, MergePolicy in)
Creates a newSoftDeletesRetentionMergePolicy
- Parameters:
field
- the soft deletes fieldretentionQuerySupplier
- a query supplier for the retention queryin
- the wrapped MergePolicy
-
-
Method Detail
-
keepFullyDeletedSegment
public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) throws IOException
Description copied from class:MergePolicy
Returns true if the segment represented by the given CodecReader should be keep even if it's fully deleted. This is useful for testing of for instance if the merge policy implements retention policies for soft deletes.- Overrides:
keepFullyDeletedSegment
in classFilterMergePolicy
- Throws:
IOException
-
numDeletesToMerge
public int numDeletesToMerge(SegmentCommitInfo info, int delCount, IOSupplier<CodecReader> readerSupplier) throws IOException
Description copied from class:MergePolicy
Returns the number of deletes that a merge would claim on the given segment. This method will by default return the sum of the del count on disk and the pending delete count. Yet, subclasses that wrap merge readers might modify this to reflect deletes that are carried over to the target segment in the case of soft deletes.Soft deletes all deletes to survive across merges in order to control when the soft-deleted data is claimed.
- Overrides:
numDeletesToMerge
in classFilterMergePolicy
- Parameters:
info
- the segment info that identifies the segmentdelCount
- the number deleted documents for this segmentreaderSupplier
- a supplier that allows to obtain aCodecReader
for this segment- Throws:
IOException
- See Also:
IndexWriter.softUpdateDocument(Term, Iterable, Field...)
,IndexWriterConfig.setSoftDeletesField(String)
-
-