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.Index.Extensions namespace. Example usage:
using Lucene.Net.Index.Extensions;
..
IndexWriterConfig conf = new IndexWriterConfig(analyzer)
.SetCodec(new Lucene46Codec())
.SetOpenMode(OpenMode.CREATE);
@since 3.1
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public sealed class IndexWriterConfig : LiveIndexWriterConfig
Constructors
| Improve this Doc View SourceIndexWriterConfig(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 SourceDEFAULT_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 |
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 |
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 |
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 |
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 |
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 |
DEFAULT_READER_POOLING
Default setting for UseReaderPooling.
Declaration
public static readonly bool DEFAULT_READER_POOLING
Field Value
Type | Description |
---|---|
System.Boolean |
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 |
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 |
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 |
DISABLE_AUTO_FLUSH
Denotes a flush trigger is disabled.
Declaration
public static readonly int DISABLE_AUTO_FLUSH
Field Value
Type | Description |
---|---|
System.Int32 |
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 SourceCodec
Gets or sets the Codec.
Only takes effect when IndexWriter is first created.
Declaration
public Codec Codec { get; set; }
Property Value
Type | Description |
---|---|
Codec |
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 |
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 |
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 |
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 |
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 |
MergeScheduler
Expert: Gets or sets the merge scheduler used by this writer. The default is ConcurrentMergeScheduler.
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 |
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 |
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
| Improve this Doc View SourceSimilarity
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 |
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 |
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 SourceClone()
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object |
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 |
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 |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |