Class UpgradeIndexMergePolicy
This MergePolicy is used for upgrading all existing segments of
an index when calling ForceMerge(Int32).
All other methods delegate to the base MergePolicy given to the constructor.
This allows for an as-cheap-as possible upgrade of an older index by only upgrading segments that
are created by previous Lucene versions. ForceMerge does no longer really merge;
it is just used to "ForceMerge" older segment versions away.
In general one would use IndexUpgrader, but for a fully customizeable upgrade,
you can use this like any other MergePolicy and call ForceMerge(Int32):
IndexWriterConfig iwc = new IndexWriterConfig(LuceneVersion.LUCENE_XX, new KeywordAnalyzer());
iwc.MergePolicy = new UpgradeIndexMergePolicy(iwc.MergePolicy);
using (IndexWriter w = new IndexWriter(dir, iwc))
{
w.ForceMerge(1);
}
Warning: this merge policy may reorder documents if the index was partially
upgraded before calling ForceMerge(Int32) (e.g., documents were added). If your application relies
on "monotonicity" of doc IDs (which means that the order in which the documents
were added to the index is preserved), do a ForceMerge(1)
instead. Please note, the
delegate MergePolicy may also reorder documents.
Note
This API is experimental and might change in incompatible ways in the next release.
Inheritance
System.Object
UpgradeIndexMergePolicy
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Lucene.Net.dll
Syntax
public class UpgradeIndexMergePolicy : MergePolicy, IDisposable
Constructors
|
Improve this Doc
View Source
UpgradeIndexMergePolicy(MergePolicy)
Declaration
public UpgradeIndexMergePolicy(MergePolicy base)
Parameters
Fields
|
Improve this Doc
View Source
m_base
Declaration
protected readonly MergePolicy m_base
Field Value
Methods
|
Improve this Doc
View Source
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
System.Boolean |
disposing |
|
Overrides
|
Improve this Doc
View Source
FindForcedDeletesMerges(SegmentInfos)
Declaration
public override MergePolicy.MergeSpecification FindForcedDeletesMerges(SegmentInfos segmentInfos)
Parameters
Returns
Overrides
|
Improve this Doc
View Source
FindForcedMerges(SegmentInfos, Int32, IDictionary<SegmentCommitInfo, Nullable<Boolean>>)
Declaration
public override MergePolicy.MergeSpecification FindForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, IDictionary<SegmentCommitInfo, bool?> segmentsToMerge)
Parameters
Type |
Name |
Description |
SegmentInfos |
segmentInfos |
|
System.Int32 |
maxSegmentCount |
|
System.Collections.Generic.IDictionary<SegmentCommitInfo, System.Nullable<System.Boolean>> |
segmentsToMerge |
|
Returns
Overrides
|
Improve this Doc
View Source
FindMerges(MergeTrigger, SegmentInfos)
Declaration
public override MergePolicy.MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos)
Parameters
Returns
Overrides
|
Improve this Doc
View Source
SetIndexWriter(IndexWriter)
Declaration
public override void SetIndexWriter(IndexWriter writer)
Parameters
Overrides
|
Improve this Doc
View Source
ShouldUpgradeSegment(SegmentCommitInfo)
Returns true
if the given segment should be upgraded. The default implementation
will return !Constants.LUCENE_MAIN_VERSION.Equals(si.Info.Version, StringComparison.Ordinal)
,
so all segments created with a different version number than this Lucene version will
get upgraded.
Declaration
protected virtual bool ShouldUpgradeSegment(SegmentCommitInfo si)
Parameters
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
|
Improve this Doc
View Source
UseCompoundFile(SegmentInfos, SegmentCommitInfo)
Declaration
public override bool UseCompoundFile(SegmentInfos segments, SegmentCommitInfo newSegment)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
Implements
System.IDisposable
See Also