Lucene.Net.Index.IndexWriter.Optimize C# (CSharp) Method

Optimize() public method

Just like Optimize(), except you can specify whether the call should block until the optimize completes. This is only meaningful with a MergeScheduler that is able to run merges in background threads.

NOTE: if this method hits an OutOfMemoryError you should immediately close the writer. See above for details.

public Optimize ( bool doWait ) : void
doWait bool
return void
		public virtual void  Optimize(bool doWait)
		{
			Optimize(1, doWait);
		}
		

Same methods

IndexWriter::Optimize ( ) : void
IndexWriter::Optimize ( int maxNumSegments ) : void
IndexWriter::Optimize ( int maxNumSegments, bool doWait ) : void

Usage Example

Ejemplo n.º 1
1
        public void SetUp()
        {

            var writer = new IndexWriter(store, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);

            var doc = new Document();
            doc.Add(new Field("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(new Field("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(new Field("contents", "Tom", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(new Field("contents", "Jerry", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(new Field("zzz", "bar", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(doc);

            writer.Optimize();
            writer.Close();
        }
All Usage Examples Of Lucene.Net.Index.IndexWriter::Optimize
IndexWriter