Introduction to Lucene 3.6.2 (2) crud for index files

Source: Internet
Author: User
Tags date create index documentation empty expression mail
Package com.jadyer.lucene;  
Import Java.io.File;  
Import java.io.IOException;  
Import Java.text.SimpleDateFormat;  
      
Import Java.util.Date;  
Import Org.apache.lucene.analysis.standard.StandardAnalyzer;  
Import org.apache.lucene.document.Document;  
Import Org.apache.lucene.document.Field;  
Import Org.apache.lucene.document.NumericField;  
Import Org.apache.lucene.index.IndexReader;  
Import Org.apache.lucene.index.IndexWriter;  
Import Org.apache.lucene.index.IndexWriterConfig;  
Import Org.apache.lucene.index.Term;  
Import Org.apache.lucene.search.IndexSearcher;  
Import Org.apache.lucene.search.Query;  
Import Org.apache.lucene.search.ScoreDoc;  
Import Org.apache.lucene.search.TermQuery;  
Import Org.apache.lucene.search.TopDocs;  
Import Org.apache.lucene.store.Directory;  
Import Org.apache.lucene.store.FSDirectory;  
      
Import org.apache.lucene.util.Version; /** * "Lucene3.6.2 Introductory Series" section No. 02 _ crud * @see for index files ================================================================================================ ============= * @see Lucene website: http://lucene.apache.org * @see Lu Cene Download: http://archive.apache.org/dist/lucene/java/* @see Lucene Documentation: http://wiki.apache.org/lucene-java/* @see = = ========================================================================================== ============= * @see View participle information using Luke (http://code.google.com/p/luke/) * @see 1) Introduction: Each Lucene version will have a corresponding Luke file * @see 2) Open: Double-click or Java-jar lukeall-3. 5.0.jar * @see 3) Select the index of the storage directory and click OK * @see 7) If our index changes, you can click on the right side of the re-open button reload the index * @see 4) Luke interface in the lower right corner of the top ranking Terms window The display is the word segmentation information. Where the rank column represents the frequency * @see 5) The documents information is displayed in the Documents tab of the Luke menu, and we can browse by the document serial number (click the arrow to the left and right) * @see 6) The Search tab under the Luke menu can be based on our loss Into the expression to look up the contents of the document * @see such as in the Enter search expression here: input Content:my, and then click on the right side of a large black word Search button can be * @see =============== ================================================================================= ============= * @create June 30, 4:34:09 PM * @authoR Xuan Yu             from:http://www.bianceng.cn writer.deletedocuments (New Term ("id", "1"));  
        Deletes the document with ID 1 in the indexed document}catch (Exception e) {e.printstacktrace ();  
                }finally{if (null!= writer) {try {writer.close ();  
                catch (IOException CE) {ce.printstacktrace (); /** * Restore Index * @see recommended discard/@Depreca  
        Ted public void Undeleteindex () {Indexreader reader = null;  try {//indexreader.open (directory) Indexreader The default readonly=true at this time, and you should specify a reader that is not read-only when you restore the index  
            Indexreader.open (directory, false); Deprecated. Write support is removed in Lucene 4.0.  
            There'll is no replacement for this method.  
        Reader.undeleteall ();  
catch (Exception e) {e.printstacktrace ();        }finally{if (null!= reader) {try {reader.close ();  
                catch (IOException e) {e.printstacktrace (); }  
            }  
        }  
    }  
}

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.