IndexWriterConfig

class IndexWriterConfig(analyzer: Analyzer = StandardAnalyzer()) : LiveIndexWriterConfig

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

All setter methods return IndexWriterConfig to allow chaining settings conveniently, for example:

IndexWriterConfig conf = new IndexWriterConfig(analyzer);
conf.setter1().setter2();
*

Since

3.1

See also

IndexWriter.getConfig

Constructors

Link copied to clipboard
constructor(analyzer: Analyzer = StandardAnalyzer())

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Specifies the open mode for IndexWriter.

Properties

Link copied to clipboard
open val analyzer: Analyzer
Link copied to clipboard

if an indexing thread should check for pending flushes on update in order to help out on a full flush

Link copied to clipboard
open lateinit var codec: Codec

Codec used to write new segments.

Link copied to clipboard

True if calls to IndexWriter.close should first do a commit.

Link copied to clipboard

Compatibility version to use for this index.

Link copied to clipboard
open lateinit var flushPolicy: FlushPolicy

FlushPolicy to control when segments are flushed.

Link copied to clipboard
open override val indexCommit: IndexCommit?
Link copied to clipboard
Link copied to clipboard

The sort order to use to write merged segments.

Link copied to clipboard

The field names involved in the index sort

Link copied to clipboard
open lateinit var infoStream: InfoStream

InfoStream for debugging messages.

Link copied to clipboard

The comparator for sorting leaf readers.

Link copied to clipboard

Returns the number of buffered added documents that will trigger a flush if enabled.

Link copied to clipboard

Amount of time to wait for merges returned by MergePolicy.findFullFlushMerges(...)

Link copied to clipboard
open lateinit var mergePolicy: MergePolicy

MergePolicy for selecting merges.

Link copied to clipboard

MergeScheduler to use for running merges.

Link copied to clipboard

OpenMode that IndexWriter is opened with.

Link copied to clipboard

parent document field

Link copied to clipboard

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

Link copied to clipboard

Returns the value set by .setRAMBufferSizeMB if enabled.

Link copied to clipboard

Sets the hard upper bound on RAM usage for a single segment, after which the segment is forced to flush.

Link copied to clipboard

True if readers should be pooled.

Link copied to clipboard
open lateinit var similarity: Similarity

Similarity to use when encoding norms.

Link copied to clipboard

soft deletes field

Link copied to clipboard

True if segment flushes should use compound file format

Functions

Link copied to clipboard

Returns the current merged segment warmer. See IndexReaderWarmer.

Link copied to clipboard
open override fun setCheckPendingFlushUpdate(checkPendingFlushOnUpdate: Boolean): IndexWriterConfig

Expert: sets if indexing threads check for pending flushes on update in order to help our flushing indexing buffers to disk. As a consequence, threads calling or IndexWriter.flush will be the only thread writing segments to disk unless flushes are falling behind. If indexing is stalled due to too many pending flushes indexing threads will help our writing pending segment flushes to disk.

Link copied to clipboard

Set the Codec.

Link copied to clipboard

Sets if calls IndexWriter.close should first commit before closing. Use true * to match behavior of Lucene 4.x.

Link copied to clipboard

Expert: Controls when segments are flushed to disk during indexing. The FlushPolicy initialized during IndexWriter instantiation and once initialized the given instance is bound to this IndexWriter and should not be used with another writer.

Link copied to clipboard

Expert: allows to open a certain commit point. The default is null which opens the latest commit point. This can also be used to open IndexWriter from a near-real-time reader, if you pass the reader's DirectoryReader.getIndexCommit.

Link copied to clipboard
fun setIndexCreatedVersionMajor(indexCreatedVersionMajor: Int): IndexWriterConfig

Expert: set the compatibility version to use for this index. In case the index is created, it will use the given major version for compatibility. It is sometimes useful to set the previous major version for compatibility due to the fact that IndexWriter.addIndexes only accepts indices that have been written with the same major version as the current index. If the index already exists, then this value is ignored. Default value is the major of the latest version.

Link copied to clipboard

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 [ ] 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.

Link copied to clipboard

Set the Sort order to use for all (flushed and merged) segments.

Link copied to clipboard

Sets the IndexWriter this config is attached to.

Link copied to clipboard

Set event listener to record key events in IndexWriter

Link copied to clipboard

Convenience method that uses PrintStreamInfoStream. Must not be null.

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

Link copied to clipboard

Set the comparator for sorting leaf readers. A DirectoryReader opened from a IndexWriter with this configuration will have its leaf readers sorted with the provided leaf sorter.

Link copied to clipboard
open override fun setMaxBufferedDocs(maxBufferedDocs: Int): IndexWriterConfig

Determines the minimal number of documents required before the buffered in-memory documents are flushed as a new Segment. Large values generally give faster indexing.

Link copied to clipboard
fun setMaxFullFlushMergeWaitMillis(maxFullFlushMergeWaitMillis: Long): IndexWriterConfig

Expert: sets the amount of time to wait for merges (during IndexWriter.commit or ) returned by MergePolicy.findFullFlushMerges(...). If this time is reached, we proceed with the commit based on segments merged up to that point. The merges are not aborted, and will still run to completion independent of the commit or getReader call, like natural segment merges. The default is {@value IndexWriterConfig#DEFAULT_MAX_FULL_FLUSH_MERGE_WAIT_MILLIS}.

Link copied to clipboard

Set the merged segment warmer. See IndexReaderWarmer.

Link copied to clipboard
open override fun setMergePolicy(mergePolicy: MergePolicy?): IndexWriterConfig

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 [ ] describing the merges. It also selects merges to do for forceMerge.

Link copied to clipboard

Expert: sets the merge scheduler used by this writer. The default is [ ].

Link copied to clipboard

Specifies OpenMode of the index.

Link copied to clipboard

Sets the parent document field. If this optional property is set, IndexWriter will add an internal field to every root document added to the index writer. A document is considered a parent document if it's the last document in a document block indexed via or IndexWriter.updateDocuments and its relatives. Additionally, all individual documents added via the single document methods (IndexWriter.addDocuments etc.) are also considered parent documents. This property is optional for all indices that don't use document blocks in combination with index sorting. In order to maintain the API guarantee that the document order of a block is not altered by the IndexWriter a marker for parent documents is required.

Link copied to clipboard
open override fun setRAMBufferSizeMB(ramBufferSizeMB: Double): IndexWriterConfig

Determines the amount of RAM that may be used for buffering added documents and deletions before they are flushed to the Directory. Generally for faster indexing performance it's best to flush by RAM usage instead of document count and use as large a RAM buffer as you can.

Link copied to clipboard
Link copied to clipboard

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 . This method lets you enable pooling without getting a near-real-time reader. NOTE: if you set this to false, IndexWriter will still pool readers once DirectoryReader.open is called.

Link copied to clipboard

Expert: set the Similarity implementation used by this IndexWriter.

Link copied to clipboard

Sets the soft-deletes field. A soft-delete field in Lucene is a doc-values field that marks a document as soft-deleted, if a document has at least one value in that field. If a document is marked as soft-deleted, the document is treated as if it has been hard-deleted through the IndexWriter API (IndexWriter.deleteDocuments. Merges will reclaim soft-deleted as well as hard-deleted documents, and index readers obtained from the IndexWriter will reflect all deleted documents in its live docs. If soft-deletes are used, documents must be indexed via IndexWriter.softUpdateDocument. Deletes are applied via IndexWriter.updateDocValues.

Link copied to clipboard
open override fun setUseCompoundFile(useCompoundFile: Boolean): IndexWriterConfig

Sets if the IndexWriter should pack newly written segments in a compound file. Default is true.

Link copied to clipboard
open override fun toString(): String