Apache Lucene.Net 2.1 Class Library API

IndexWriter Class

An IndexWriter creates and maintains an index.

The third argument (

create
) to the constructor determines whether a new index is created, or whether an existing index is opened for the addition of new documents. Note that you can open an index with create=true even while readers are using the index. The old readers will continue to search the "point in time" snapshot they had opened, and won't see the newly created index until they re-open.

In either case, documents are added with the addDocument method. When finished adding documents, close should be called.

If an index will not have more documents added for a while and optimal search performance is desired, then the optimize method should be called before the index is closed.

Opening an IndexWriter creates a lock file for the directory in use. Trying to open another IndexWriter on the same directory will lead to an IOException. The IOException is also thrown if an IndexReader on the same directory is used to delete documents from the index.

As of 2.1, IndexWriter can now delete documents by {@link Term} (see {@link #deleteDocuments} ) and update (delete then add) documents (see {@link #updateDocument}). Deletes are buffered until {@link #setMaxBufferedDeleteTerms}

Terms
at which point they are flushed to the index. Note that a flush occurs when there are enough buffered deletes or enough added documents, whichever is sooner. When a flush occurs, both pending deletes and added documents are flushed to the index.

For a list of all members of this type, see IndexWriter Members.

System.Object
   Lucene.Net.Index.IndexWriter

public class IndexWriter

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: Lucene.Net.Index

Assembly: Lucene.Net (in Lucene.Net.dll)

See Also

IndexWriter Members | Lucene.Net.Index Namespace