[Note that as of 2.1, all but one of the /// methods in this class are available via {@link /// IndexWriter}. The one method that is not available is /// {@link #DeleteDocument(int)}.]
/// /// A class to modify an index, i.e. to delete and add documents. This /// class hides {@link IndexReader} and {@link IndexWriter} so that you /// do not need to care about implementation details such as that adding /// documents is done via IndexWriter and deletion is done via IndexReader. /// ///Note that you cannot create more than one IndexModifier
object
/// on the same directory at the same time.
///
///
Example usage: /// /// /// /// /// ///
///
/// Analyzer analyzer = new StandardAnalyzer();
/// |
///
///
Not all methods of IndexReader and IndexWriter are offered by this
/// class. If you need access to additional methods, either use those classes
/// directly or implement your own class that extends IndexModifier
.
///
///
Although an instance of this class can be used from more than one /// thread, you will not get the best performance. You might want to use /// IndexReader and IndexWriter directly for that (but you will need to /// care about synchronization yourself then). /// ///
While you can freely mix calls to add() and delete() using this class, /// you should batch you calls for best performance. For example, if you /// want to update 20 documents, you should first delete all those documents, /// then add all the new documents. /// ///
true
to create the index or overwrite the existing one;
/// false
to append to the existing index
///
public IndexModifier(Directory directory, Analyzer analyzer, bool create)
{
InitBlock();
Init(directory, analyzer, create);
}
/// true
to create the index or overwrite the existing one;
/// false
to append to the existing index
///
public IndexModifier(System.String dirName, Analyzer analyzer, bool create)
{
InitBlock();
Directory dir = FSDirectory.GetDirectory(dirName);
Init(dir, analyzer, create);
}
/// true
to create the index or overwrite the existing one;
/// false
to append to the existing index
///
public IndexModifier(System.IO.FileInfo file, Analyzer analyzer, bool create)
{
InitBlock();
Directory dir = FSDirectory.GetDirectory(file);
Init(dir, analyzer, create);
}
/// term
.
/// This is useful if one uses a document field to hold a unique ID string for
/// the document. Then to delete such a document, one merely constructs a
/// term with the appropriate field and the unique ID string as its text and
/// passes it to this method. Returns the number of documents deleted.
/// docNum
.Example: index.setInfoStream(System.err); ///
The default value is 10. /// ///
This must never be less than 2. The default value is 10. /// ///