The Indexmodifier method of Lucene

Source: Internet
Author: User

/*
* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.