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. OnceIndexWriterhas been created with this object, changes to this object will not affect theIndexWriterinstance. For that, useLiveIndexWriterConfigthat is returned fromIndexWriter.getConfig().All setter methods return
IndexWriterConfigto 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 classIndexWriterConfig.OpenModeSpecifies the open mode forIndexWriter.
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_COMMIT_ON_CLOSEDefault value for whether calls toIndexWriter.close()include a commit.static intDEFAULT_MAX_BUFFERED_DELETE_TERMSDisabled by default (because IndexWriter flushes by RAM usage by default).static intDEFAULT_MAX_BUFFERED_DOCSDisabled by default (because IndexWriter flushes by RAM usage by default).static longDEFAULT_MAX_FULL_FLUSH_MERGE_WAIT_MILLISDefault value for time to wait for merges on commit or getReader (when using aMergePolicythat implementsMergePolicy.findFullFlushMerges(org.apache.lucene.index.MergeTrigger, org.apache.lucene.index.SegmentInfos, org.apache.lucene.index.MergePolicy.MergeContext)).static doubleDEFAULT_RAM_BUFFER_SIZE_MBDefault value is 16 MB (which means flush when buffered docs consume approximately 16 MB RAM).static intDEFAULT_RAM_PER_THREAD_HARD_LIMIT_MBDefault value is 1945.static booleanDEFAULT_READER_POOLINGDefault setting (true) forsetReaderPooling(boolean).static booleanDEFAULT_USE_COMPOUND_FILE_SYSTEMDefault value for compound file system for newly written segments (set totrue).static intDISABLE_AUTO_FLUSHDenotes 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, parentField, perThreadHardLimitMB, readerPooling, similarity, softDeletesField, useCompoundFile
-
-
Constructor Summary
Constructors Constructor Description IndexWriterConfig()Creates a new config, usingStandardAnalyzeras 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 AnalyzergetAnalyzer()Returns the default analyzer to use for indexing documents.CodecgetCodec()Returns the currentCodec.IndexCommitgetIndexCommit()Returns theIndexCommitas specified insetIndexCommit(IndexCommit)or the default,nullwhich specifies to open the latest index commit point.IndexDeletionPolicygetIndexDeletionPolicy()Returns theIndexDeletionPolicyspecified insetIndexDeletionPolicy(IndexDeletionPolicy)or the defaultKeepOnlyLastCommitDeletionPolicy/InfoStreamgetInfoStream()ReturnsInfoStreamused for debugging.intgetMaxBufferedDocs()Returns the number of buffered added documents that will trigger a flush if enabled.IndexWriter.IndexReaderWarmergetMergedSegmentWarmer()Returns the current merged segment warmer.MergePolicygetMergePolicy()Returns the current MergePolicy in use by this writer.MergeSchedulergetMergeScheduler()Returns theMergeSchedulerthat was set bysetMergeScheduler(MergeScheduler).IndexWriterConfig.OpenModegetOpenMode()Returns theIndexWriterConfig.OpenModeset bysetOpenMode(OpenMode).doublegetRAMBufferSizeMB()Returns the value set byLiveIndexWriterConfig.setRAMBufferSizeMB(double)if enabled.intgetRAMPerThreadHardLimitMB()Returns the max amount of memory eachDocumentsWriterPerThreadcan consume until forcefully flushed.booleangetReaderPooling()ReturnstrueifIndexWritershould pool readers even ifDirectoryReader.open(IndexWriter)has not been called.SimilaritygetSimilarity()Expert: returns theSimilarityimplementation used by thisIndexWriter.IndexWriterConfigsetCheckPendingFlushUpdate(boolean checkPendingFlushOnUpdate)Expert: sets if indexing threads check for pending flushes on update in order to help our flushing indexing buffers to disk.IndexWriterConfigsetCodec(Codec codec)Set theCodec.IndexWriterConfigsetCommitOnClose(boolean commitOnClose)Sets if callsIndexWriter.close()should first commit before closing.IndexWriterConfigsetIndexCommit(IndexCommit commit)Expert: allows to open a certain commit point.IndexWriterConfigsetIndexCreatedVersionMajor(int indexCreatedVersionMajor)Expert: set the compatibility version to use for this index.IndexWriterConfigsetIndexDeletionPolicy(IndexDeletionPolicy delPolicy)Expert: allows an optionalIndexDeletionPolicyimplementation to be specified.IndexWriterConfigsetIndexSort(Sort sort)Set theSortorder to use for all (flushed and merged) segments.IndexWriterConfigsetIndexWriterEventListener(IndexWriterEventListener eventListener)Set event listener to record key events in IndexWriterIndexWriterConfigsetInfoStream(PrintStream printStream)Convenience method that usesPrintStreamInfoStream.IndexWriterConfigsetInfoStream(InfoStream infoStream)Information about merges, deletes and a message when maxFieldLength is reached will be printed to this.IndexWriterConfigsetLeafSorter(Comparator<LeafReader> leafSorter)Set the comparator for sorting leaf readers.IndexWriterConfigsetMaxBufferedDocs(int maxBufferedDocs)Determines the minimal number of documents required before the buffered in-memory documents are flushed as a new Segment.IndexWriterConfigsetMaxFullFlushMergeWaitMillis(long maxFullFlushMergeWaitMillis)Expert: sets the amount of time to wait for merges (duringIndexWriter.commit()orIndexWriter.getReader(boolean, boolean)) returned by MergePolicy.findFullFlushMerges(...).IndexWriterConfigsetMergedSegmentWarmer(IndexWriter.IndexReaderWarmer mergeSegmentWarmer)Set the merged segment warmer.IndexWriterConfigsetMergePolicy(MergePolicy mergePolicy)Expert:MergePolicyis invoked whenever there are changes to the segments in the index.IndexWriterConfigsetMergeScheduler(MergeScheduler mergeScheduler)Expert: sets the merge scheduler used by this writer.IndexWriterConfigsetOpenMode(IndexWriterConfig.OpenMode openMode)SpecifiesIndexWriterConfig.OpenModeof the index.IndexWriterConfigsetParentField(String parentField)Sets the parent document field.IndexWriterConfigsetRAMBufferSizeMB(double ramBufferSizeMB)Determines the amount of RAM that may be used for buffering added documents and deletions before they are flushed to the Directory.IndexWriterConfigsetRAMPerThreadHardLimitMB(int perThreadHardLimitMB)Expert: Sets the maximum memory consumption per thread triggering a forced flush if exceeded.IndexWriterConfigsetReaderPooling(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).IndexWriterConfigsetSimilarity(Similarity similarity)Expert: set theSimilarityimplementation used by this IndexWriter.IndexWriterConfigsetSoftDeletesField(String softDeletesField)Sets the soft deletes field.IndexWriterConfigsetUseCompoundFile(boolean useCompoundFile)Sets if theIndexWritershould pack newly written segments in a compound file.StringtoString()-
Methods inherited from class org.apache.lucene.index.LiveIndexWriterConfig
getCommitOnClose, getIndexCreatedVersionMajor, getIndexSort, getIndexSortFields, getIndexWriterEventListener, getLeafSorter, getMaxFullFlushMergeWaitMillis, getParentField, 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 aMergePolicythat 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, usingStandardAnalyzeras the analyzer. By default,TieredMergePolicyis used for merging; Note thatTieredMergePolicyis free to select non-contiguous merges, which means docIDs may not remain monotonic over time. If this is a problem you should switch toLogByteSizeMergePolicyorLogDocMergePolicy.
-
IndexWriterConfig
public IndexWriterConfig(Analyzer analyzer)
Creates a new config that with the providedAnalyzer. By default,TieredMergePolicyis used for merging; Note thatTieredMergePolicyis free to select non-contiguous merges, which means docIDs may not remain monotonic over time. If this is a problem you should switch toLogByteSizeMergePolicyorLogDocMergePolicy.
-
-
Method Detail
-
setOpenMode
public IndexWriterConfig setOpenMode(IndexWriterConfig.OpenMode openMode)
SpecifiesIndexWriterConfig.OpenModeof the index.Only takes effect when IndexWriter is first created.
-
getOpenMode
public IndexWriterConfig.OpenMode getOpenMode()
Description copied from class:LiveIndexWriterConfigReturns theIndexWriterConfig.OpenModeset bysetOpenMode(OpenMode).- Overrides:
getOpenModein 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 themajorof 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 optionalIndexDeletionPolicyimplementation to be specified. You can use this to control when prior commits are deleted from the index. The default policy isKeepOnlyLastCommitDeletionPolicywhich 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:LiveIndexWriterConfigReturns theIndexDeletionPolicyspecified insetIndexDeletionPolicy(IndexDeletionPolicy)or the defaultKeepOnlyLastCommitDeletionPolicy/- Overrides:
getIndexDeletionPolicyin 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 openIndexWriterfrom 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:LiveIndexWriterConfigReturns theIndexCommitas specified insetIndexCommit(IndexCommit)or the default,nullwhich specifies to open the latest index commit point.- Overrides:
getIndexCommitin classLiveIndexWriterConfig
-
setSimilarity
public IndexWriterConfig setSimilarity(Similarity similarity)
Expert: set theSimilarityimplementation 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:LiveIndexWriterConfigExpert: returns theSimilarityimplementation used by thisIndexWriter.- Overrides:
getSimilarityin 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:LiveIndexWriterConfigReturns theMergeSchedulerthat was set bysetMergeScheduler(MergeScheduler).- Overrides:
getMergeSchedulerin 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:LiveIndexWriterConfigReturns the currentCodec.- Overrides:
getCodecin classLiveIndexWriterConfig
-
getMergePolicy
public MergePolicy getMergePolicy()
Description copied from class:LiveIndexWriterConfigReturns the current MergePolicy in use by this writer.- Overrides:
getMergePolicyin 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:LiveIndexWriterConfigReturnstrueifIndexWritershould pool readers even ifDirectoryReader.open(IndexWriter)has not been called.- Overrides:
getReaderPoolingin classLiveIndexWriterConfig
-
setRAMPerThreadHardLimitMB
public IndexWriterConfig setRAMPerThreadHardLimitMB(int perThreadHardLimitMB)
Expert: Sets the maximum memory consumption per thread triggering a forced flush if exceeded. ADocumentsWriterPerThreadis forcefully flushed once it exceeds this limit even if thegetRAMBufferSizeMB()has not been exceeded. This is a safety limit to prevent aDocumentsWriterPerThreadfrom 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:LiveIndexWriterConfigReturns the max amount of memory eachDocumentsWriterPerThreadcan consume until forcefully flushed.- Overrides:
getRAMPerThreadHardLimitMBin classLiveIndexWriterConfig- See Also:
setRAMPerThreadHardLimitMB(int)
-
getInfoStream
public InfoStream getInfoStream()
Description copied from class:LiveIndexWriterConfigReturnsInfoStreamused for debugging.- Overrides:
getInfoStreamin classLiveIndexWriterConfig- See Also:
setInfoStream(InfoStream)
-
getAnalyzer
public Analyzer getAnalyzer()
Description copied from class:LiveIndexWriterConfigReturns the default analyzer to use for indexing documents.- Overrides:
getAnalyzerin classLiveIndexWriterConfig
-
getMaxBufferedDocs
public int getMaxBufferedDocs()
Description copied from class:LiveIndexWriterConfigReturns the number of buffered added documents that will trigger a flush if enabled.- Overrides:
getMaxBufferedDocsin classLiveIndexWriterConfig- See Also:
LiveIndexWriterConfig.setMaxBufferedDocs(int)
-
getMergedSegmentWarmer
public IndexWriter.IndexReaderWarmer getMergedSegmentWarmer()
Description copied from class:LiveIndexWriterConfigReturns the current merged segment warmer. SeeIndexWriter.IndexReaderWarmer.- Overrides:
getMergedSegmentWarmerin classLiveIndexWriterConfig
-
getRAMBufferSizeMB
public double getRAMBufferSizeMB()
Description copied from class:LiveIndexWriterConfigReturns the value set byLiveIndexWriterConfig.setRAMBufferSizeMB(double)if enabled.- Overrides:
getRAMBufferSizeMBin 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_OUTPUTmay 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:LiveIndexWriterConfigExpert:MergePolicyis 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.MergeSpecificationdescribing 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
MergePolicyare not affected.- Overrides:
setMergePolicyin classLiveIndexWriterConfig
-
setMaxBufferedDocs
public IndexWriterConfig setMaxBufferedDocs(int maxBufferedDocs)
Description copied from class:LiveIndexWriterConfigDetermines 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_FLUSHto 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:
setMaxBufferedDocsin classLiveIndexWriterConfig- See Also:
LiveIndexWriterConfig.setRAMBufferSizeMB(double)
-
setMergedSegmentWarmer
public IndexWriterConfig setMergedSegmentWarmer(IndexWriter.IndexReaderWarmer mergeSegmentWarmer)
Description copied from class:LiveIndexWriterConfigSet the merged segment warmer. SeeIndexWriter.IndexReaderWarmer.Takes effect on the next merge.
- Overrides:
setMergedSegmentWarmerin classLiveIndexWriterConfig
-
setRAMBufferSizeMB
public IndexWriterConfig setRAMBufferSizeMB(double ramBufferSizeMB)
Description copied from class:LiveIndexWriterConfigDetermines 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_FLUSHto 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
IndexWritersession 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
FlushPolicyonly 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:
setRAMBufferSizeMBin classLiveIndexWriterConfig- See Also:
setRAMPerThreadHardLimitMB(int)
-
setUseCompoundFile
public IndexWriterConfig setUseCompoundFile(boolean useCompoundFile)
Description copied from class:LiveIndexWriterConfigSets if theIndexWritershould pack newly written segments in a compound file. Default istrue.Use
falsefor 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:
setUseCompoundFilein classLiveIndexWriterConfig
-
setCommitOnClose
public IndexWriterConfig setCommitOnClose(boolean commitOnClose)
Sets if callsIndexWriter.close()should first commit before closing. Usetrueto 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
SerialMergeScheduleris 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 theSortorder 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:
toStringin classLiveIndexWriterConfig
-
setCheckPendingFlushUpdate
public IndexWriterConfig setCheckPendingFlushUpdate(boolean checkPendingFlushOnUpdate)
Description copied from class:LiveIndexWriterConfigExpert: 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:
setCheckPendingFlushUpdatein 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.
SoftDeletesRetentionMergePolicyfor 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
nullwhich 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
-
setParentField
public IndexWriterConfig setParentField(String parentField)
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 viaIndexWriter.addDocuments(Iterable)orIndexWriter.updateDocuments(Term, Iterable)and its relatives. Additionally, all individual documents added via the single document methods (IndexWriter.addDocuments(Iterable)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 theIndexWritera marker for parent documents is required.
-
-