Class IndexWriterConfig
- java.lang.Object
-
- org.apache.lucene.index.LiveIndexWriterConfig
-
- org.apache.lucene.index.IndexWriterConfig
-
public final class IndexWriterConfig extends LiveIndexWriterConfig
Holds all the configuration that is used to create anIndexWriter
. OnceIndexWriter
has been created with this object, changes to this object will not affect theIndexWriter
instance. For that, useLiveIndexWriterConfig
that is returned fromIndexWriter.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()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IndexWriterConfig.OpenMode
Specifies the open mode forIndexWriter
.
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_COMMIT_ON_CLOSE
Default value for whether calls toIndexWriter.close()
include a commit.static int
DEFAULT_MAX_BUFFERED_DELETE_TERMS
Disabled by default (because IndexWriter flushes by RAM usage by default).static int
DEFAULT_MAX_BUFFERED_DOCS
Disabled by default (because IndexWriter flushes by RAM usage by default).static long
DEFAULT_MAX_FULL_FLUSH_MERGE_WAIT_MILLIS
Default value for time to wait for merges on commit or getReader (when using aMergePolicy
that implementsMergePolicy.findFullFlushMerges(org.apache.lucene.index.MergeTrigger, org.apache.lucene.index.SegmentInfos, org.apache.lucene.index.MergePolicy.MergeContext)
).static double
DEFAULT_RAM_BUFFER_SIZE_MB
Default value is 16 MB (which means flush when buffered docs consume approximately 16 MB RAM).static int
DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB
Default value is 1945.static boolean
DEFAULT_READER_POOLING
Default setting (true) forsetReaderPooling(boolean)
.static boolean
DEFAULT_USE_COMPOUND_FILE_SYSTEM
Default value for compound file system for newly written segments (set totrue
).static int
DISABLE_AUTO_FLUSH
Denotes a flush trigger is disabled.-
Fields inherited from class org.apache.lucene.index.LiveIndexWriterConfig
checkPendingFlushOnUpdate, codec, commit, commitOnClose, createdVersionMajor, delPolicy, eventListener, flushPolicy, indexSort, indexSortFields, infoStream, leafSorter, maxFullFlushMergeWaitMillis, mergePolicy, mergeScheduler, openMode, perThreadHardLimitMB, readerPooling, similarity, softDeletesField, useCompoundFile
-
-
Constructor Summary
Constructors Constructor Description IndexWriterConfig()
Creates a new config, usingStandardAnalyzer
as the analyzer.IndexWriterConfig(Analyzer analyzer)
Creates a new config that with the providedAnalyzer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Analyzer
getAnalyzer()
Returns the default analyzer to use for indexing documents.Codec
getCodec()
Returns the currentCodec
.IndexCommit
getIndexCommit()
Returns theIndexCommit
as specified insetIndexCommit(IndexCommit)
or the default,null
which specifies to open the latest index commit point.IndexDeletionPolicy
getIndexDeletionPolicy()
Returns theIndexDeletionPolicy
specified insetIndexDeletionPolicy(IndexDeletionPolicy)
or the defaultKeepOnlyLastCommitDeletionPolicy
/InfoStream
getInfoStream()
ReturnsInfoStream
used for debugging.int
getMaxBufferedDocs()
Returns the number of buffered added documents that will trigger a flush if enabled.IndexWriter.IndexReaderWarmer
getMergedSegmentWarmer()
Returns the current merged segment warmer.MergePolicy
getMergePolicy()
Returns the current MergePolicy in use by this writer.MergeScheduler
getMergeScheduler()
Returns theMergeScheduler
that was set bysetMergeScheduler(MergeScheduler)
.IndexWriterConfig.OpenMode
getOpenMode()
Returns theIndexWriterConfig.OpenMode
set bysetOpenMode(OpenMode)
.double
getRAMBufferSizeMB()
Returns the value set byLiveIndexWriterConfig.setRAMBufferSizeMB(double)
if enabled.int
getRAMPerThreadHardLimitMB()
Returns the max amount of memory eachDocumentsWriterPerThread
can consume until forcefully flushed.boolean
getReaderPooling()
Returnstrue
ifIndexWriter
should pool readers even ifDirectoryReader.open(IndexWriter)
has not been called.Similarity
getSimilarity()
Expert: returns theSimilarity
implementation used by thisIndexWriter
.IndexWriterConfig
setCheckPendingFlushUpdate(boolean checkPendingFlushOnUpdate)
Expert: sets if indexing threads check for pending flushes on update in order to help our flushing indexing buffers to disk.IndexWriterConfig
setCodec(Codec codec)
Set theCodec
.IndexWriterConfig
setCommitOnClose(boolean commitOnClose)
Sets if callsIndexWriter.close()
should first commit before closing.IndexWriterConfig
setIndexCommit(IndexCommit commit)
Expert: allows to open a certain commit point.IndexWriterConfig
setIndexCreatedVersionMajor(int indexCreatedVersionMajor)
Expert: set the compatibility version to use for this index.IndexWriterConfig
setIndexDeletionPolicy(IndexDeletionPolicy delPolicy)
Expert: allows an optionalIndexDeletionPolicy
implementation to be specified.IndexWriterConfig
setIndexSort(Sort sort)
Set theSort
order to use for all (flushed and merged) segments.IndexWriterConfig
setIndexWriterEventListener(IndexWriterEventListener eventListener)
Set event listener to record key events in IndexWriterIndexWriterConfig
setInfoStream(PrintStream printStream)
Convenience method that usesPrintStreamInfoStream
.IndexWriterConfig
setInfoStream(InfoStream infoStream)
Information about merges, deletes and a message when maxFieldLength is reached will be printed to this.IndexWriterConfig
setLeafSorter(Comparator<LeafReader> leafSorter)
Set the comparator for sorting leaf readers.IndexWriterConfig
setMaxBufferedDocs(int maxBufferedDocs)
Determines the minimal number of documents required before the buffered in-memory documents are flushed as a new Segment.IndexWriterConfig
setMaxFullFlushMergeWaitMillis(long maxFullFlushMergeWaitMillis)
Expert: sets the amount of time to wait for merges (duringIndexWriter.commit()
orIndexWriter.getReader(boolean, boolean)
) returned by MergePolicy.findFullFlushMerges(...).IndexWriterConfig
setMergedSegmentWarmer(IndexWriter.IndexReaderWarmer mergeSegmentWarmer)
Set the merged segment warmer.IndexWriterConfig
setMergePolicy(MergePolicy mergePolicy)
Expert:MergePolicy
is invoked whenever there are changes to the segments in the index.IndexWriterConfig
setMergeScheduler(MergeScheduler mergeScheduler)
Expert: sets the merge scheduler used by this writer.IndexWriterConfig
setOpenMode(IndexWriterConfig.OpenMode openMode)
SpecifiesIndexWriterConfig.OpenMode
of the index.IndexWriterConfig
setRAMBufferSizeMB(double ramBufferSizeMB)
Determines the amount of RAM that may be used for buffering added documents and deletions before they are flushed to the Directory.IndexWriterConfig
setRAMPerThreadHardLimitMB(int perThreadHardLimitMB)
Expert: Sets the maximum memory consumption per thread triggering a forced flush if exceeded.IndexWriterConfig
setReaderPooling(boolean readerPooling)
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 callingDirectoryReader.open(IndexWriter)
.IndexWriterConfig
setSimilarity(Similarity similarity)
Expert: set theSimilarity
implementation used by this IndexWriter.IndexWriterConfig
setSoftDeletesField(String softDeletesField)
Sets the soft deletes field.IndexWriterConfig
setUseCompoundFile(boolean useCompoundFile)
Sets if theIndexWriter
should pack newly written segments in a compound file.String
toString()
-
Methods inherited from class org.apache.lucene.index.LiveIndexWriterConfig
getCommitOnClose, getIndexCreatedVersionMajor, getIndexSort, getIndexSortFields, getIndexWriterEventListener, getLeafSorter, getMaxFullFlushMergeWaitMillis, getSoftDeletesField, getUseCompoundFile, isCheckPendingFlushOnUpdate
-
-
-
-
Field Detail
-
DISABLE_AUTO_FLUSH
public static final int DISABLE_AUTO_FLUSH
Denotes a flush trigger is disabled.- See Also:
- Constant Field Values
-
DEFAULT_MAX_BUFFERED_DELETE_TERMS
public static final int DEFAULT_MAX_BUFFERED_DELETE_TERMS
Disabled by default (because IndexWriter flushes by RAM usage by default).- See Also:
- Constant Field Values
-
DEFAULT_MAX_BUFFERED_DOCS
public static final int DEFAULT_MAX_BUFFERED_DOCS
Disabled by default (because IndexWriter flushes by RAM usage by default).- See Also:
- Constant Field Values
-
DEFAULT_RAM_BUFFER_SIZE_MB
public static final double DEFAULT_RAM_BUFFER_SIZE_MB
Default value is 16 MB (which means flush when buffered docs consume approximately 16 MB RAM).- See Also:
- Constant Field Values
-
DEFAULT_READER_POOLING
public static final boolean DEFAULT_READER_POOLING
Default setting (true) forsetReaderPooling(boolean)
.- See Also:
- Constant Field Values
-
DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB
public static final int DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB
Default value is 1945. Change usingsetRAMPerThreadHardLimitMB(int)
- See Also:
- Constant Field Values
-
DEFAULT_USE_COMPOUND_FILE_SYSTEM
public static final boolean DEFAULT_USE_COMPOUND_FILE_SYSTEM
Default value for compound file system for newly written segments (set totrue
). For batch indexing with very large ram buffers usefalse
- See Also:
- Constant Field Values
-
DEFAULT_COMMIT_ON_CLOSE
public static final boolean DEFAULT_COMMIT_ON_CLOSE
Default value for whether calls toIndexWriter.close()
include a commit.- See Also:
- Constant Field Values
-
DEFAULT_MAX_FULL_FLUSH_MERGE_WAIT_MILLIS
public static final long DEFAULT_MAX_FULL_FLUSH_MERGE_WAIT_MILLIS
Default value for time to wait for merges on commit or getReader (when using aMergePolicy
that implementsMergePolicy.findFullFlushMerges(org.apache.lucene.index.MergeTrigger, org.apache.lucene.index.SegmentInfos, org.apache.lucene.index.MergePolicy.MergeContext)
).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndexWriterConfig
public IndexWriterConfig()
Creates a new config, usingStandardAnalyzer
as the analyzer. By default,TieredMergePolicy
is used for merging; Note thatTieredMergePolicy
is free to select non-contiguous merges, which means docIDs may not remain monotonic over time. If this is a problem you should switch toLogByteSizeMergePolicy
orLogDocMergePolicy
.
-
IndexWriterConfig
public IndexWriterConfig(Analyzer analyzer)
Creates a new config that with the providedAnalyzer
. By default,TieredMergePolicy
is used for merging; Note thatTieredMergePolicy
is free to select non-contiguous merges, which means docIDs may not remain monotonic over time. If this is a problem you should switch toLogByteSizeMergePolicy
orLogDocMergePolicy
.
-
-
Method Detail
-
setOpenMode
public IndexWriterConfig setOpenMode(IndexWriterConfig.OpenMode openMode)
SpecifiesIndexWriterConfig.OpenMode
of the index.Only takes effect when IndexWriter is first created.
-
getOpenMode
public IndexWriterConfig.OpenMode getOpenMode()
Description copied from class:LiveIndexWriterConfig
Returns theIndexWriterConfig.OpenMode
set bysetOpenMode(OpenMode)
.- Overrides:
getOpenMode
in classLiveIndexWriterConfig
-
setIndexCreatedVersionMajor
public IndexWriterConfig setIndexCreatedVersionMajor(int indexCreatedVersionMajor)
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 thatIndexWriter.addIndexes(org.apache.lucene.store.Directory...)
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 themajor
of thelatest version
.NOTE: Changing the creation version reduces backward compatibility guarantees. For instance an index created with Lucene 8 with a compatibility version of 7 can't be read with Lucene 9 due to the fact that Lucene only supports reading indices created with the current or previous major release.
- Parameters:
indexCreatedVersionMajor
- the major version to use for compatibility
-
setIndexDeletionPolicy
public IndexWriterConfig setIndexDeletionPolicy(IndexDeletionPolicy delPolicy)
Expert: allows an optionalIndexDeletionPolicy
implementation to be specified. You can use this to control when prior commits are deleted from the index. The default policy isKeepOnlyLastCommitDeletionPolicy
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 must not be null.
Only takes effect when IndexWriter is first created.
-
getIndexDeletionPolicy
public IndexDeletionPolicy getIndexDeletionPolicy()
Description copied from class:LiveIndexWriterConfig
Returns theIndexDeletionPolicy
specified insetIndexDeletionPolicy(IndexDeletionPolicy)
or the defaultKeepOnlyLastCommitDeletionPolicy
/- Overrides:
getIndexDeletionPolicy
in classLiveIndexWriterConfig
-
setIndexCommit
public IndexWriterConfig setIndexCommit(IndexCommit commit)
Expert: allows to open a certain commit point. The default is null which opens the latest commit point. This can also be used to openIndexWriter
from a near-real-time reader, if you pass the reader'sDirectoryReader.getIndexCommit()
.Only takes effect when IndexWriter is first created.
-
getIndexCommit
public IndexCommit getIndexCommit()
Description copied from class:LiveIndexWriterConfig
Returns theIndexCommit
as specified insetIndexCommit(IndexCommit)
or the default,null
which specifies to open the latest index commit point.- Overrides:
getIndexCommit
in classLiveIndexWriterConfig
-
setSimilarity
public IndexWriterConfig setSimilarity(Similarity similarity)
Expert: set theSimilarity
implementation used by this IndexWriter.NOTE: the similarity must not be null.
Only takes effect when IndexWriter is first created.
-
getSimilarity
public Similarity getSimilarity()
Description copied from class:LiveIndexWriterConfig
Expert: returns theSimilarity
implementation used by thisIndexWriter
.- Overrides:
getSimilarity
in classLiveIndexWriterConfig
-
setMergeScheduler
public IndexWriterConfig setMergeScheduler(MergeScheduler mergeScheduler)
Expert: sets the merge scheduler used by this writer. The default isConcurrentMergeScheduler
.NOTE: the merge scheduler must not be null.
Only takes effect when IndexWriter is first created.
-
getMergeScheduler
public MergeScheduler getMergeScheduler()
Description copied from class:LiveIndexWriterConfig
Returns theMergeScheduler
that was set bysetMergeScheduler(MergeScheduler)
.- Overrides:
getMergeScheduler
in classLiveIndexWriterConfig
-
setCodec
public IndexWriterConfig setCodec(Codec codec)
Set theCodec
.Only takes effect when IndexWriter is first created.
-
getCodec
public Codec getCodec()
Description copied from class:LiveIndexWriterConfig
Returns the currentCodec
.- Overrides:
getCodec
in classLiveIndexWriterConfig
-
getMergePolicy
public MergePolicy getMergePolicy()
Description copied from class:LiveIndexWriterConfig
Returns the current MergePolicy in use by this writer.- Overrides:
getMergePolicy
in classLiveIndexWriterConfig
- See Also:
setMergePolicy(MergePolicy)
-
setReaderPooling
public IndexWriterConfig setReaderPooling(boolean readerPooling)
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 callingDirectoryReader.open(IndexWriter)
. 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 onceDirectoryReader.open(IndexWriter)
is called.Only takes effect when IndexWriter is first created.
-
getReaderPooling
public boolean getReaderPooling()
Description copied from class:LiveIndexWriterConfig
Returnstrue
ifIndexWriter
should pool readers even ifDirectoryReader.open(IndexWriter)
has not been called.- Overrides:
getReaderPooling
in classLiveIndexWriterConfig
-
setRAMPerThreadHardLimitMB
public IndexWriterConfig setRAMPerThreadHardLimitMB(int perThreadHardLimitMB)
Expert: Sets the maximum memory consumption per thread triggering a forced flush if exceeded. ADocumentsWriterPerThread
is forcefully flushed once it exceeds this limit even if thegetRAMBufferSizeMB()
has not been exceeded. This is a safety limit to prevent aDocumentsWriterPerThread
from address space exhaustion due to its internal 32 bit signed integer based memory addressing. The given value must be less that 2GB (2048MB)- See Also:
DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB
-
getRAMPerThreadHardLimitMB
public int getRAMPerThreadHardLimitMB()
Description copied from class:LiveIndexWriterConfig
Returns the max amount of memory eachDocumentsWriterPerThread
can consume until forcefully flushed.- Overrides:
getRAMPerThreadHardLimitMB
in classLiveIndexWriterConfig
- See Also:
setRAMPerThreadHardLimitMB(int)
-
getInfoStream
public InfoStream getInfoStream()
Description copied from class:LiveIndexWriterConfig
ReturnsInfoStream
used for debugging.- Overrides:
getInfoStream
in classLiveIndexWriterConfig
- See Also:
setInfoStream(InfoStream)
-
getAnalyzer
public Analyzer getAnalyzer()
Description copied from class:LiveIndexWriterConfig
Returns the default analyzer to use for indexing documents.- Overrides:
getAnalyzer
in classLiveIndexWriterConfig
-
getMaxBufferedDocs
public int getMaxBufferedDocs()
Description copied from class:LiveIndexWriterConfig
Returns the number of buffered added documents that will trigger a flush if enabled.- Overrides:
getMaxBufferedDocs
in classLiveIndexWriterConfig
- See Also:
LiveIndexWriterConfig.setMaxBufferedDocs(int)
-
getMergedSegmentWarmer
public IndexWriter.IndexReaderWarmer getMergedSegmentWarmer()
Description copied from class:LiveIndexWriterConfig
Returns the current merged segment warmer. SeeIndexWriter.IndexReaderWarmer
.- Overrides:
getMergedSegmentWarmer
in classLiveIndexWriterConfig
-
getRAMBufferSizeMB
public double getRAMBufferSizeMB()
Description copied from class:LiveIndexWriterConfig
Returns the value set byLiveIndexWriterConfig.setRAMBufferSizeMB(double)
if enabled.- Overrides:
getRAMBufferSizeMB
in classLiveIndexWriterConfig
-
setInfoStream
public IndexWriterConfig setInfoStream(InfoStream infoStream)
Information about merges, deletes and a message when maxFieldLength is reached will be printed to this. Must not be null, butInfoStream.NO_OUTPUT
may be used to suppress output.
-
setInfoStream
public IndexWriterConfig setInfoStream(PrintStream printStream)
Convenience method that usesPrintStreamInfoStream
. Must not be null.
-
setMergePolicy
public IndexWriterConfig setMergePolicy(MergePolicy mergePolicy)
Description copied from class:LiveIndexWriterConfig
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 aMergePolicy.MergeSpecification
describing the merges. It also selects merges to do for forceMerge.Takes effect on subsequent merge selections. Any merges in flight or any merges already registered by the previous
MergePolicy
are not affected.- Overrides:
setMergePolicy
in classLiveIndexWriterConfig
-
setMaxBufferedDocs
public IndexWriterConfig setMaxBufferedDocs(int maxBufferedDocs)
Description copied from class:LiveIndexWriterConfig
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.When this is set, the writer will flush every maxBufferedDocs added documents. Pass in
DISABLE_AUTO_FLUSH
to prevent triggering a flush due to number of buffered documents. Note that if flushing by RAM usage is also enabled, then the flush will be triggered by whichever comes first.Disabled by default (writer flushes by RAM usage).
Takes effect immediately, but only the next time a document is added, updated or deleted.
- Overrides:
setMaxBufferedDocs
in classLiveIndexWriterConfig
- See Also:
LiveIndexWriterConfig.setRAMBufferSizeMB(double)
-
setMergedSegmentWarmer
public IndexWriterConfig setMergedSegmentWarmer(IndexWriter.IndexReaderWarmer mergeSegmentWarmer)
Description copied from class:LiveIndexWriterConfig
Set the merged segment warmer. SeeIndexWriter.IndexReaderWarmer
.Takes effect on the next merge.
- Overrides:
setMergedSegmentWarmer
in classLiveIndexWriterConfig
-
setRAMBufferSizeMB
public IndexWriterConfig setRAMBufferSizeMB(double ramBufferSizeMB)
Description copied from class:LiveIndexWriterConfig
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.When this is set, the writer will flush whenever buffered documents and deletions use this much RAM. Pass in
DISABLE_AUTO_FLUSH
to prevent triggering a flush due to RAM usage. Note that if flushing by document count is also enabled, then the flush will be triggered by whichever comes first.The maximum RAM limit is inherently determined by the JVMs available memory. Yet, an
IndexWriter
session can consume a significantly larger amount of memory than the given RAM limit since this limit is just an indicator when to flush memory resident documents to the Directory. Flushes are likely happen concurrently while other threads adding documents to the writer. For application stability the available memory in the JVM should be significantly larger than the RAM buffer used for indexing.NOTE: the account of RAM usage for pending deletions is only approximate. Specifically, if you delete by Query, Lucene currently has no way to measure the RAM usage of individual Queries so the accounting will under-estimate and you should compensate by either calling commit() or refresh() periodically yourself.
NOTE: It's not guaranteed that all memory resident documents are flushed once this limit is exceeded. Depending on the configured
FlushPolicy
only a subset of the buffered documents are flushed and therefore only parts of the RAM buffer is released.The default value is
DEFAULT_RAM_BUFFER_SIZE_MB
.Takes effect immediately, but only the next time a document is added, updated or deleted.
- Overrides:
setRAMBufferSizeMB
in classLiveIndexWriterConfig
- See Also:
setRAMPerThreadHardLimitMB(int)
-
setUseCompoundFile
public IndexWriterConfig setUseCompoundFile(boolean useCompoundFile)
Description copied from class:LiveIndexWriterConfig
Sets if theIndexWriter
should pack newly written segments in a compound file. Default istrue
.Use
false
for batch indexing with very large ram buffer settings.Note: To control compound file usage during segment merges see
MergePolicy.setNoCFSRatio(double)
andMergePolicy.setMaxCFSSegmentSizeMB(double)
. This setting only applies to newly created segments.- Overrides:
setUseCompoundFile
in classLiveIndexWriterConfig
-
setCommitOnClose
public IndexWriterConfig setCommitOnClose(boolean commitOnClose)
Sets if callsIndexWriter.close()
should first commit before closing. Usetrue
to match behavior of Lucene 4.x.
-
setMaxFullFlushMergeWaitMillis
public IndexWriterConfig setMaxFullFlushMergeWaitMillis(long maxFullFlushMergeWaitMillis)
Expert: sets the amount of time to wait for merges (duringIndexWriter.commit()
orIndexWriter.getReader(boolean, boolean)
) 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 is500L
.Note: Which segments would get merged depends on the implementation of
MergePolicy.findFullFlushMerges(MergeTrigger, SegmentInfos, MergePolicy.MergeContext)
Note: Set to 0 to disable merging on full flush.
Note: If
SerialMergeScheduler
is used and a non-zero timout is configured, full-flush merges will always wait for the merge to finish without honoring the configured timeout.
-
setIndexSort
public IndexWriterConfig setIndexSort(Sort sort)
Set theSort
order to use for all (flushed and merged) segments.
-
setLeafSorter
public IndexWriterConfig setLeafSorter(Comparator<LeafReader> leafSorter)
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.- Parameters:
leafSorter
- – a comparator for sorting leaf readers- Returns:
- IndexWriterConfig with leafSorter set.
-
toString
public String toString()
- Overrides:
toString
in classLiveIndexWriterConfig
-
setCheckPendingFlushUpdate
public IndexWriterConfig setCheckPendingFlushUpdate(boolean checkPendingFlushOnUpdate)
Description copied from class:LiveIndexWriterConfig
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 callingDirectoryReader.openIfChanged(DirectoryReader, IndexWriter)
orIndexWriter.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.- Overrides:
setCheckPendingFlushUpdate
in classLiveIndexWriterConfig
-
setSoftDeletesField
public IndexWriterConfig setSoftDeletesField(String softDeletesField)
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(Term...)
. Merges will reclaim soft-deleted as well as hard-deleted documents and index readers obtained from the IndexWriter will reflect all deleted documents in it's live docs. If soft-deletes are used documents must be indexed viaIndexWriter.softUpdateDocument(Term, Iterable, Field...)
. Deletes are applied viaIndexWriter.updateDocValues(Term, Field...)
.Soft deletes allow to retain documents across merges if the merge policy modifies the live docs of a merge reader.
SoftDeletesRetentionMergePolicy
for instance allows to specify an arbitrary query to mark all documents that should survive the merge. This can be used to for example keep all document modifications for a certain time interval or the last N operations if some kind of sequence ID is available in the index.Currently there is no API support to un-delete a soft-deleted document. In oder to un-delete the document must be re-indexed using
IndexWriter.softUpdateDocument(Term, Iterable, Field...)
.The default value for this is
null
which disables soft-deletes. If soft-deletes are enabled documents can still be hard-deleted. Hard-deleted documents will won't considered as soft-deleted even if they have a value in the soft-deletes field.
-
setIndexWriterEventListener
public IndexWriterConfig setIndexWriterEventListener(IndexWriterEventListener eventListener)
Set event listener to record key events in IndexWriter
-
-