org.apache.lucene.index
Class RandomIndexWriter

java.lang.Object
  extended by org.apache.lucene.index.RandomIndexWriter
All Implemented Interfaces:
Closeable

public class RandomIndexWriter
extends Object
implements Closeable

Silly class that randomizes the indexing experience. EG it may swap in a different merge policy/scheduler; may commit periodically; may or may not optimize in the end, may flush by doc count instead of RAM, etc.


Field Summary
 org.apache.lucene.index.IndexWriter w
           
 
Constructor Summary
RandomIndexWriter(Random r, org.apache.lucene.store.Directory dir)
          create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT and Whitespace+LowercasingAnalyzer
RandomIndexWriter(Random r, org.apache.lucene.store.Directory dir, org.apache.lucene.analysis.Analyzer a)
          create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT
RandomIndexWriter(Random r, org.apache.lucene.store.Directory dir, org.apache.lucene.index.IndexWriterConfig c)
          create a RandomIndexWriter with the provided config
RandomIndexWriter(Random r, org.apache.lucene.store.Directory dir, org.apache.lucene.util.Version v, org.apache.lucene.analysis.Analyzer a)
          create a RandomIndexWriter with a random config
 
Method Summary
 void addDocument(org.apache.lucene.document.Document doc)
          Adds a Document.
 void addIndexes(org.apache.lucene.store.Directory... dirs)
           
 void close()
          Close this writer.
 void commit()
           
 void deleteAll()
           
 void deleteDocuments(org.apache.lucene.index.Term term)
           
 org.apache.lucene.index.IndexReader getReader()
           
 int maxDoc()
           
 int numDocs()
           
 void optimize()
          Forces an optimize.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

w

public org.apache.lucene.index.IndexWriter w
Constructor Detail

RandomIndexWriter

public RandomIndexWriter(Random r,
                         org.apache.lucene.store.Directory dir)
                  throws IOException
create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT and Whitespace+LowercasingAnalyzer

Throws:
IOException

RandomIndexWriter

public RandomIndexWriter(Random r,
                         org.apache.lucene.store.Directory dir,
                         org.apache.lucene.analysis.Analyzer a)
                  throws IOException
create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT

Throws:
IOException

RandomIndexWriter

public RandomIndexWriter(Random r,
                         org.apache.lucene.store.Directory dir,
                         org.apache.lucene.util.Version v,
                         org.apache.lucene.analysis.Analyzer a)
                  throws IOException
create a RandomIndexWriter with a random config

Throws:
IOException

RandomIndexWriter

public RandomIndexWriter(Random r,
                         org.apache.lucene.store.Directory dir,
                         org.apache.lucene.index.IndexWriterConfig c)
                  throws IOException
create a RandomIndexWriter with the provided config

Throws:
IOException
Method Detail

addDocument

public void addDocument(org.apache.lucene.document.Document doc)
                 throws IOException
Adds a Document.

Throws:
IOException
See Also:
IndexWriter.addDocument(Document)

addIndexes

public void addIndexes(org.apache.lucene.store.Directory... dirs)
                throws org.apache.lucene.index.CorruptIndexException,
                       IOException
Throws:
org.apache.lucene.index.CorruptIndexException
IOException

deleteDocuments

public void deleteDocuments(org.apache.lucene.index.Term term)
                     throws org.apache.lucene.index.CorruptIndexException,
                            IOException
Throws:
org.apache.lucene.index.CorruptIndexException
IOException

commit

public void commit()
            throws org.apache.lucene.index.CorruptIndexException,
                   IOException
Throws:
org.apache.lucene.index.CorruptIndexException
IOException

numDocs

public int numDocs()
            throws IOException
Throws:
IOException

maxDoc

public int maxDoc()

deleteAll

public void deleteAll()
               throws IOException
Throws:
IOException

getReader

public org.apache.lucene.index.IndexReader getReader()
                                              throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Close this writer.

Specified by:
close in interface Closeable
Throws:
IOException
See Also:
IndexWriter.close()

optimize

public void optimize()
              throws IOException
Forces an optimize.

NOTE: this should be avoided in tests unless absolutely necessary, as it will result in less test coverage.

Throws:
IOException
See Also:
IndexWriter.optimize()


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.