Class SortingMergePolicy
A Lucene.Net.Index.MergePolicy that reorders documents according to a Lucene.Net.Search.Sort 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 policy if you rely on IndexWriter.AddDocuments to have sequentially-assigned doc IDs, this policy will scatter doc IDs.
NOTE: This policy should only be used with idempotent Lucene.Net.Search.Sorts so that the order of segments is predictable. For example, using Lucene.Net.Search.Sort.INDEXORDER in reverse (which is not idempotent) will make the order of documents in a segment depend on the number of times the segment has been merged.
Note
This API is experimental and might change in incompatible ways in the next release.
Implements
Inherited Members
Namespace: Lucene.Net.Index.Sorter
Assembly: Lucene.Net.Misc.dll
Syntax
public sealed class SortingMergePolicy : MergePolicy, IDisposable
Constructors
SortingMergePolicy(MergePolicy, Sort)
Create a new Lucene.Net.Index.MergePolicy that sorts documents with the given sort.
Declaration
public SortingMergePolicy(MergePolicy @in, Sort sort)
Parameters
| Type | Name | Description |
|---|---|---|
| MergePolicy | in | |
| Sort | sort |
Fields
SORTER_ID_PROP
Put in the diagnostics to denote that this segment is sorted.
Declaration
public static readonly string SORTER_ID_PROP
Field Value
| Type | Description |
|---|---|
| string |
Methods
Clone()
A Lucene.Net.Index.MergePolicy that reorders documents according to a Lucene.Net.Search.Sort 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 policy if you rely on IndexWriter.AddDocuments to have sequentially-assigned doc IDs, this policy will scatter doc IDs.
NOTE: This policy should only be used with idempotent Lucene.Net.Search.Sorts so that the order of segments is predictable. For example, using Lucene.Net.Search.Sort.INDEXORDER in reverse (which is not idempotent) will make the order of documents in a segment depend on the number of times the segment has been merged.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public override object Clone()
Returns
| Type | Description |
|---|---|
| object |
Overrides
Dispose(bool)
Release all resources for the policy.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
Overrides
FindForcedDeletesMerges(SegmentInfos)
Determine what set of merge operations is necessary in order to expunge all deletes from the index.
Declaration
public override MergePolicy.MergeSpecification FindForcedDeletesMerges(SegmentInfos segmentInfos)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentInfos | segmentInfos | the total set of segments in the index |
Returns
| Type | Description |
|---|---|
| MergePolicy.MergeSpecification |
Overrides
FindForcedMerges(SegmentInfos, int, IDictionary<SegmentCommitInfo, bool>)
Determine what set of merge operations is necessary in order to merge to <= the specified segment count. Lucene.Net.Index.IndexWriter calls this when its ForceMerge(int, bool) method is called. This call is always synchronized on the Lucene.Net.Index.IndexWriter instance so only one thread at a time will call this method.
Declaration
public override MergePolicy.MergeSpecification FindForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, IDictionary<SegmentCommitInfo, bool> segmentsToMerge)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentInfos | segmentInfos | The total set of segments in the index |
| int | maxSegmentCount | Requested maximum number of segments in the index (currently this is always 1) |
| IDictionary<SegmentCommitInfo, bool> | segmentsToMerge | Contains the specific Lucene.Net.Index.SegmentInfo instances that must be merged
away. This may be a subset of all
SegmentInfos. If the value is |
Returns
| Type | Description |
|---|---|
| MergePolicy.MergeSpecification |
Overrides
FindMerges(MergeTrigger, SegmentInfos)
Determine what set of merge operations are now necessary on the index. Lucene.Net.Index.IndexWriter calls this whenever there is a change to the segments. This call is always synchronized on the Lucene.Net.Index.IndexWriter instance so only one thread at a time will call this method.
Declaration
public override MergePolicy.MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos)
Parameters
| Type | Name | Description |
|---|---|---|
| MergeTrigger | mergeTrigger | the event that triggered the merge |
| SegmentInfos | segmentInfos | the total set of segments in the index |
Returns
| Type | Description |
|---|---|
| MergePolicy.MergeSpecification |
Overrides
IsSorted(AtomicReader, Sort)
Returns true if the given reader is sorted by the specified sort.
Declaration
public static bool IsSorted(AtomicReader reader, Sort sort)
Parameters
| Type | Name | Description |
|---|---|---|
| AtomicReader | reader | |
| Sort | sort |
Returns
| Type | Description |
|---|---|
| bool |
SetIndexWriter(IndexWriter)
Sets the Lucene.Net.Index.IndexWriter to use by this merge policy. This method is allowed to be called only once, and is usually set by Lucene.Net.Index.IndexWriter. If it is called more than once, Lucene.Net.Util.AlreadySetException is thrown.
Declaration
public override void SetIndexWriter(IndexWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| IndexWriter | writer |
Overrides
See Also
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents the current object. |
Overrides
UseCompoundFile(SegmentInfos, SegmentCommitInfo)
Returns true if a new segment (regardless of its origin) should use the
compound file format. The default implementation returns true
iff the size of the given mergedInfo is less or equal to
Lucene.Net.Index.MergePolicy.MaxCFSSegmentSizeMB and the size is less or equal to the
TotalIndexSize * Lucene.Net.Index.MergePolicy.NoCFSRatio otherwise
false.
Declaration
public override bool UseCompoundFile(SegmentInfos segments, SegmentCommitInfo newSegment)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentInfos | segments | |
| SegmentCommitInfo | newSegment |
Returns
| Type | Description |
|---|---|
| bool |