/*
* This code is to reflect the new content of Lucene2.0, Indexmodifier class.
* This class and the basic function of the IndexWriter class is the same, just more than the indexreader of the index delete function
* */
Package indexreader;
Import Org.apache.lucene.analysis.standard.StandardAnalyzer;
Import org.apache.lucene.document.Document;
Import Org.apache.lucene.document.Field;
public class Indexmodifier {
Private String Index_store_path = "E:\\lucene project \ \ Index Directory";
The default constructor
Public Indexmodifier () {
}
overriding constructors
Public Indexmodifier (String index_store_path2, StandardAnalyzer StandardAnalyzer, Boolean b) {
Indexmodifier modifier = new Indexmodifier (index_store_path2, New StandardAnalyzer (), true);
Creating a Document 1
Document Doc1 = new document ();
Field bookName1 = new Field ("BookName", "How Steel is Tempered", Field.Store.YES, Field.Index.TOKENIZED);
Doc1.add (BOOKNAME1);
Creating a Document 2
Document DOC2 = new document ();
Field bookName2 = new Field ("BookName", "Children of Heroes", Field.Store.YES, Field.Index.TOKENIZED);
Doc2.add (bookName2);
Modifier.adddocument (Doc1);
Modifier.adddocument (DOC2);
System.out.println (Modifier.doccount ());
Modifier.close ();
}
public static void Main (string[] args) {
TODO auto-generated Method Stub
}
}
The Indexmodifier method of Lucene