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

Optimize() public method

Optimize the index down to <= maxNumSegments. If maxNumSegments==1 then this is the same as Optimize() .

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

public Optimize ( int maxNumSegments ) : void
maxNumSegments int maximum number of segments left /// in the index after optimization finishes ///
return void
		public virtual void  Optimize(int maxNumSegments)
		{
			Optimize(maxNumSegments, true);
		}
		

Same methods

IndexWriter::Optimize ( ) : void
IndexWriter::Optimize ( bool doWait ) : 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