Lucene.Net.Index.IndexWriterConfig.SetIndexDeletionPolicy C# (CSharp) Method

SetIndexDeletionPolicy() public method

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.

public SetIndexDeletionPolicy ( IndexDeletionPolicy deletionPolicy ) : IndexWriterConfig
deletionPolicy IndexDeletionPolicy
return IndexWriterConfig
        public IndexWriterConfig SetIndexDeletionPolicy(IndexDeletionPolicy deletionPolicy)
        {
            if (deletionPolicy == null)
            {
                throw new System.ArgumentException("indexDeletionPolicy must not be null");
            }
            this.delPolicy = deletionPolicy;
            return this;
        }

Usage Example

        protected internal virtual IndexWriterConfig GetConfig(Random random, IndexDeletionPolicy dp)
        {
            IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));

            if (dp != null)
            {
                conf.SetIndexDeletionPolicy(dp);
            }
            return(conf);
        }
All Usage Examples Of Lucene.Net.Index.IndexWriterConfig::SetIndexDeletionPolicy