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
Inherited Members
Assembly: DistributedLucene.Net.dll
Syntax
public sealed class IndexWriterConfig : LiveIndexWriterConfig
Constructors
Name | Description |
---|---|
IndexWriterConfig(LuceneVersion, Analyzer) | Creates a new config that with defaults that match the specified
LuceneVersion as well as the default
Analyzer. If |
Fields
Name | Description |
---|---|
DEFAULT_CHECK_INTEGRITY_AT_MERGE | Default value for calling CheckIntegrity() before
merging segments (set to |
DEFAULT_MAX_BUFFERED_DELETE_TERMS | Disabled by default (because IndexWriter flushes by RAM usage by default). |
DEFAULT_MAX_BUFFERED_DOCS | Disabled by default (because IndexWriter flushes by RAM usage by default). |
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. |
DEFAULT_RAM_BUFFER_SIZE_MB | Default value is 16 MB (which means flush when buffered docs consume approximately 16 MB RAM). |
DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB | Default value is 1945. Change using RAMPerThreadHardLimitMB setter. |
DEFAULT_READER_POOLING | Default setting for UseReaderPooling. |
DEFAULT_READER_TERMS_INDEX_DIVISOR | Default value is 1. Change using ReaderTermsIndexDivisor setter. |
DEFAULT_TERM_INDEX_INTERVAL | Default value is 32. Change using TermIndexInterval setter. |
DEFAULT_USE_COMPOUND_FILE_SYSTEM | Default value for compound file system for newly written segments
(set to |
DISABLE_AUTO_FLUSH | Denotes a flush trigger is disabled. |
WRITE_LOCK_TIMEOUT | Default value for the write lock timeout (1,000 ms). |
Properties
Name | Description |
---|---|
Codec | Gets or sets the Codec. Only takes effect when IndexWriter is first created. |
DefaultWriteLockTimeout | Gets or sets the default (for any instance) maximum time to wait for a write lock (in milliseconds). |
IndexCommit | Expert: allows to open a certain commit point. The default is Only takes effect when IndexWriter is first created. |
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 Only takes effect when IndexWriter is first created. |
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
Only takes effect when IndexWriter is first created. |
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. |
MergeScheduler | Expert: Gets or sets the merge scheduler used by this writer. The default is ConcurrentMergeScheduler.
NOTE: the merge scheduler cannot be Only takes effect when IndexWriter is first created. |
OpenMode | Specifies OpenMode of the index. Only takes effect when IndexWriter is first created. |
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). |
Similarity | Expert: set the Similarity implementation used by this IndexWriter.
NOTE: the similarity cannot be Only takes effect when IndexWriter is first created. |
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
Only takes effect when IndexWriter is first created. |
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. |
Methods
Name | Description |
---|---|
Clone() | |
SetInfoStream(InfoStream) | Information about merges, deletes and a
message when maxFieldLength is reached will be printed
to this. Must not be |
SetInfoStream(TextWriter) | Convenience method that uses TextWriterInfoStream to write to the passed in |
ToString() |