Show / Hide Table of Contents

    Class IndexWriterConfig

    Holds all the configuration that is used to create an IndexWriter. Once IndexWriter has been created with this object, changes to this object will not affect the IndexWriter instance. For that, use LiveIndexWriterConfig that is returned from Config.

    LUCENENET NOTE: Unlike Lucene, we use property setters instead of setter methods. In C#, this allows you to initialize the IndexWriterConfig using the language features of C#, for example:

        IndexWriterConfig conf = new IndexWriterConfig(analyzer)
        {
            Codec = Lucene46Codec(),
            OpenMode = OpenMode.CREATE
        };

    However, if you prefer to match the syntax of Lucene using chained setter methods, there are extension methods in the Lucene.Net.Support namespace. Example usage:

        using Lucene.Net.Support;
    
        ..
    
        IndexWriterConfig conf = new IndexWriterConfig(analyzer)
            .SetCodec(new Lucene46Codec())
            .SetOpenMode(OpenMode.CREATE);

    @since 3.1

    Inheritance
    System.Object
    LiveIndexWriterConfig
    IndexWriterConfig
    Inherited Members
    LiveIndexWriterConfig.Analyzer
    LiveIndexWriterConfig.TermIndexInterval
    LiveIndexWriterConfig.MaxBufferedDeleteTerms
    LiveIndexWriterConfig.RAMBufferSizeMB
    LiveIndexWriterConfig.MaxBufferedDocs
    LiveIndexWriterConfig.MergedSegmentWarmer
    LiveIndexWriterConfig.ReaderTermsIndexDivisor
    LiveIndexWriterConfig.InfoStream
    LiveIndexWriterConfig.UseCompoundFile
    LiveIndexWriterConfig.CheckIntegrityAtMerge
    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)
    Namespace: Lucene.Net.Index
    Assembly: Lucene.Net.dll
    Syntax
    public sealed class IndexWriterConfig : LiveIndexWriterConfig

    Constructors

    | Improve this Doc View Source

    IndexWriterConfig(LuceneVersion, Analyzer)

    Creates a new config that with defaults that match the specified LuceneVersion as well as the default Analyzer. If matchVersion is >= LUCENE_32, TieredMergePolicy is used for merging; else LogByteSizeMergePolicy. Note that TieredMergePolicy is free to select non-contiguous merges, which means docIDs may not remain monotonic over time. If this is a problem you should switch to LogByteSizeMergePolicy or LogDocMergePolicy.

    Declaration
    public IndexWriterConfig(LuceneVersion matchVersion, Analyzer analyzer)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Analyzer analyzer

    Fields

    | Improve this Doc View Source

    DEFAULT_CHECK_INTEGRITY_AT_MERGE

    Default value for calling CheckIntegrity() before merging segments (set to false). You can set this to true for additional safety.

    Declaration
    public static readonly bool DEFAULT_CHECK_INTEGRITY_AT_MERGE
    Field Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    DEFAULT_MAX_BUFFERED_DELETE_TERMS

    Disabled by default (because IndexWriter flushes by RAM usage by default).

    Declaration
    public static readonly int DEFAULT_MAX_BUFFERED_DELETE_TERMS
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_MAX_BUFFERED_DOCS

    Disabled by default (because IndexWriter flushes by RAM usage by default).

    Declaration
    public static readonly int DEFAULT_MAX_BUFFERED_DOCS
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_MAX_THREAD_STATES

    The maximum number of simultaneous threads that may be indexing documents at once in IndexWriter; if more than this many threads arrive they will wait for others to finish. Default value is 8.

    Declaration
    public static readonly int DEFAULT_MAX_THREAD_STATES
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_RAM_BUFFER_SIZE_MB

    Default value is 16 MB (which means flush when buffered docs consume approximately 16 MB RAM).

    Declaration
    public static readonly double DEFAULT_RAM_BUFFER_SIZE_MB
    Field Value
    Type Description
    System.Double
    | Improve this Doc View Source

    DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB

    Default value is 1945. Change using RAMPerThreadHardLimitMB setter.

    Declaration
    public static readonly int DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_READER_POOLING

    Default setting for UseReaderPooling.

    Declaration
    public static readonly bool DEFAULT_READER_POOLING
    Field Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    DEFAULT_READER_TERMS_INDEX_DIVISOR

    Default value is 1. Change using ReaderTermsIndexDivisor setter.

    Declaration
    public static readonly int DEFAULT_READER_TERMS_INDEX_DIVISOR
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_TERM_INDEX_INTERVAL

    Default value is 32. Change using TermIndexInterval setter.

    Declaration
    public static readonly int DEFAULT_TERM_INDEX_INTERVAL
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_USE_COMPOUND_FILE_SYSTEM

    Default value for compound file system for newly written segments (set to true). For batch indexing with very large ram buffers use false

    Declaration
    public static readonly bool DEFAULT_USE_COMPOUND_FILE_SYSTEM
    Field Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    DISABLE_AUTO_FLUSH

    Denotes a flush trigger is disabled.

    Declaration
    public static readonly int DISABLE_AUTO_FLUSH
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    WRITE_LOCK_TIMEOUT

    Default value for the write lock timeout (1,000 ms).

    Declaration
    public static long WRITE_LOCK_TIMEOUT
    Field Value
    Type Description
    System.Int64

    Properties

    | Improve this Doc View Source

    Codec

    Gets or sets the Codec.

    Only takes effect when IndexWriter is first created.

    Declaration
    public Codec Codec { get; set; }
    Property Value
    Type Description
    Codec
    | Improve this Doc View Source

    DefaultWriteLockTimeout

    Gets or sets the default (for any instance) maximum time to wait for a write lock (in milliseconds).

    Declaration
    public static long DefaultWriteLockTimeout { get; set; }
    Property Value
    Type Description
    System.Int64
    | Improve this Doc View Source

    IndexCommit

    Expert: allows to open a certain commit point. The default is null which opens the latest commit point.

    Only takes effect when IndexWriter is first created.

    Declaration
    public IndexCommit IndexCommit { get; set; }
    Property Value
    Type Description
    IndexCommit
    | Improve this Doc View Source

    IndexDeletionPolicy

    Expert: allows an optional IndexDeletionPolicy implementation to be specified. You can use this to control when prior commits are deleted from the index. The default policy is KeepOnlyLastCommitDeletionPolicy which removes all prior commits as soon as a new commit is done (this matches behavior before 2.2). Creating your own policy can allow you to explicitly keep previous "point in time" commits alive in the index for some time, to allow readers to refresh to the new commit without having the old commit deleted out from under them. This is necessary on filesystems like NFS that do not support "delete on last close" semantics, which Lucene's "point in time" search normally relies on.

    NOTE: the deletion policy cannot be null.

    Only takes effect when IndexWriter is first created.

    Declaration
    public IndexDeletionPolicy IndexDeletionPolicy { get; set; }
    Property Value
    Type Description
    IndexDeletionPolicy
    | Improve this Doc View Source

    MaxThreadStates

    Gets or sets the max number of simultaneous threads that may be indexing documents at once in IndexWriter. Values < 1 are invalid and if passed maxThreadStates will be set to DEFAULT_MAX_THREAD_STATES.

    Only takes effect when IndexWriter is first created.

    Declaration
    public int MaxThreadStates { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    MergePolicy

    Expert: MergePolicy is invoked whenever there are changes to the segments in the index. Its role is to select which merges to do, if any, and return a MergePolicy.MergeSpecification describing the merges. It also selects merges to do for ForceMerge(Int32).

    Only takes effect when IndexWriter is first created.

    Declaration
    public MergePolicy MergePolicy { get; set; }
    Property Value
    Type Description
    MergePolicy
    | Improve this Doc View Source

    MergeScheduler

    Expert: Gets or sets the merge scheduler used by this writer. The default is TaskMergeScheduler.

    NOTE: the merge scheduler cannot be null.

    Only takes effect when IndexWriter is first created.

    Declaration
    public IMergeScheduler MergeScheduler { get; set; }
    Property Value
    Type Description
    IMergeScheduler
    | Improve this Doc View Source

    OpenMode

    Specifies OpenMode of the index.

    Only takes effect when IndexWriter is first created.

    Declaration
    public OpenMode OpenMode { get; set; }
    Property Value
    Type Description
    OpenMode
    | Improve this Doc View Source

    RAMPerThreadHardLimitMB

    Expert: Gets or sets the maximum memory consumption per thread triggering a forced flush if exceeded. A Lucene.Net.Index.DocumentsWriterPerThread is forcefully flushed once it exceeds this limit even if the RAMBufferSizeMB has not been exceeded. This is a safety limit to prevent a Lucene.Net.Index.DocumentsWriterPerThread from address space exhaustion due to its internal 32 bit signed integer based memory addressing. The given value must be less that 2GB (2048MB).

    Declaration
    public int RAMPerThreadHardLimitMB { get; set; }
    Property Value
    Type Description
    System.Int32
    See Also
    DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB
    | Improve this Doc View Source

    Similarity

    Expert: set the Similarity implementation used by this IndexWriter.

    NOTE: the similarity cannot be null.

    Only takes effect when IndexWriter is first created.

    Declaration
    public Similarity Similarity { get; set; }
    Property Value
    Type Description
    Similarity
    | Improve this Doc View Source

    UseReaderPooling

    By default, IndexWriter does not pool the SegmentReaders it must open for deletions and merging, unless a near-real-time reader has been obtained by calling Open(IndexWriter, Boolean). this setting lets you enable pooling without getting a near-real-time reader. NOTE: if you set this to false, IndexWriter will still pool readers once Open(IndexWriter, Boolean) is called.

    Only takes effect when IndexWriter is first created.

    Declaration
    public bool UseReaderPooling { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    WriteLockTimeout

    Gets or sets the maximum time to wait for a write lock (in milliseconds) for this instance. You can change the default value for all instances by calling the DefaultWriteLockTimeout setter.

    Only takes effect when IndexWriter is first created.

    Declaration
    public long WriteLockTimeout { get; set; }
    Property Value
    Type Description
    System.Int64

    Methods

    | Improve this Doc View Source

    Clone()

    Declaration
    public object Clone()
    Returns
    Type Description
    System.Object
    | Improve this Doc View Source

    SetInfoStream(InfoStream)

    Information about merges, deletes and a message when maxFieldLength is reached will be printed to this. Must not be null, but NO_OUTPUT may be used to supress output.

    Declaration
    public IndexWriterConfig SetInfoStream(InfoStream infoStream)
    Parameters
    Type Name Description
    InfoStream infoStream
    Returns
    Type Description
    IndexWriterConfig
    | Improve this Doc View Source

    SetInfoStream(TextWriter)

    Convenience method that uses TextWriterInfoStream to write to the passed in System.IO.TextWriter. Must not be null.

    Declaration
    public IndexWriterConfig SetInfoStream(TextWriter printStream)
    Parameters
    Type Name Description
    System.IO.TextWriter printStream
    Returns
    Type Description
    IndexWriterConfig
    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    LiveIndexWriterConfig.ToString()

    Extension Methods

    IndexWriterConfigExtensions.SetTermIndexInterval(LiveIndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetMaxBufferedDeleteTerms(LiveIndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetRAMBufferSizeMB(LiveIndexWriterConfig, Double)
    IndexWriterConfigExtensions.SetMaxBufferedDocs(LiveIndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetMergedSegmentWarmer(LiveIndexWriterConfig, IndexWriter.IndexReaderWarmer)
    IndexWriterConfigExtensions.SetReaderTermsIndexDivisor(LiveIndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetUseCompoundFile(LiveIndexWriterConfig, Boolean)
    IndexWriterConfigExtensions.SetCheckIntegrityAtMerge(LiveIndexWriterConfig, Boolean)
    IndexWriterConfigExtensions.SetTermIndexInterval(IndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetMaxBufferedDeleteTerms(IndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetRAMBufferSizeMB(IndexWriterConfig, Double)
    IndexWriterConfigExtensions.SetMaxBufferedDocs(IndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetMergedSegmentWarmer(IndexWriterConfig, IndexWriter.IndexReaderWarmer)
    IndexWriterConfigExtensions.SetReaderTermsIndexDivisor(IndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetUseCompoundFile(IndexWriterConfig, Boolean)
    IndexWriterConfigExtensions.SetCheckIntegrityAtMerge(IndexWriterConfig, Boolean)
    IndexWriterConfigExtensions.SetDefaultWriteLockTimeout(IndexWriterConfig, Int64)
    IndexWriterConfigExtensions.SetOpenMode(IndexWriterConfig, OpenMode)
    IndexWriterConfigExtensions.SetIndexDeletionPolicy(IndexWriterConfig, IndexDeletionPolicy)
    IndexWriterConfigExtensions.SetIndexCommit(IndexWriterConfig, IndexCommit)
    IndexWriterConfigExtensions.SetSimilarity(IndexWriterConfig, Similarity)
    IndexWriterConfigExtensions.SetMergeScheduler(IndexWriterConfig, IMergeScheduler)
    IndexWriterConfigExtensions.SetWriteLockTimeout(IndexWriterConfig, Int64)
    IndexWriterConfigExtensions.SetMergePolicy(IndexWriterConfig, MergePolicy)
    IndexWriterConfigExtensions.SetCodec(IndexWriterConfig, Codec)
    IndexWriterConfigExtensions.SetMaxThreadStates(IndexWriterConfig, Int32)
    IndexWriterConfigExtensions.SetReaderPooling(IndexWriterConfig, Boolean)
    IndexWriterConfigExtensions.SetRAMPerThreadHardLimitMB(IndexWriterConfig, Int32)
    Number.IsNumber(Object)

    See Also

    Config
    • Improve this Doc
    • View Source
    Back to top Copyright © 2019 Licensed to the Apache Software Foundation (ASF)