Getting Started with Lucene 3.6.2 (1) First program: Hello Word

Source: Internet
Author: User
Tags create directory create index createindex
Package com.jadyer.lucene;  
Import Java.io.File;  
Import Java.io.FileReader;  
      
Import java.io.IOException;  
Import Org.apache.lucene.analysis.standard.StandardAnalyzer;  
Import org.apache.lucene.document.Document;  
Import Org.apache.lucene.document.Field;  
Import Org.apache.lucene.index.IndexReader;  
Import Org.apache.lucene.index.IndexWriter;  
Import Org.apache.lucene.index.IndexWriterConfig;  
Import Org.apache.lucene.queryParser.QueryParser;  
Import Org.apache.lucene.search.IndexSearcher;  
Import Org.apache.lucene.search.Query;  
Import Org.apache.lucene.search.ScoreDoc;  
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" No. 01 _helloword * @see Here is only a lucene-core-3.6.2.jar * @see Lucene website: http://lucene.apache.org * @see lucene Download: http://archive.apache.org/dist/lucene/java/* @see Lucene Documentation: HTTP://WIki.apache.org/lucene-java/* @see------------------------------------------------------------------------------- ------------------------------* @see 1) for Full-text search tools, are indexed, participle, search three components * @see 2) are stored and indexed, is two independent concept * @see---------------  ----------------------------------------------------------------------------------------------* Storage options for @see domain * @see 
 field.store.yes--will store the contents of the domain in a file for easy text restoration * @see Field.Store.NO---means that the contents of the domain are not stored in the file, but are allowed to be indexed and the content cannot be fully restored (Doc.get ("#")) * @see---------------------------------------------------------------------------------------------------------- ---* @see domain index Options * @see Field.Index.ANALYZED----------------for Word segmentation and indexing, for headings, content, etc. * @see Field.Index.NOT_ANALYZED------

------Indexed but not participle (such as ID card number, name, ID, etc.), suitable for accurate search * @see Field.Index.ANALYZED_NOT_NORMS------for Word segmentation but does not store norms information, this norms includes the creation of a cable The time and weight of the cited information * @see field.index.not_analyzed_not_norms--that is not to do participle and not store norms information * @see Field.Index.NO----------------------do not index * @see norms: when data is searched, it involves sorting problems, while the sort is someScoring rules, the information of these sorts is stored in the norms * @see--------------------------------------------------------------------------------     -----------------------------* @see Domain option Best practices * @see field.store field.index field value * @see YES        Not_analyzed_not_norms identifiers (primary key, filename), phone number, ID number, name, date * @see YES analyzed document title and summary * @see No analyzed document body * @see no not_analyzed hidden keyword * @see YES N O document type, database primary key (not indexed) * @see----------------------------------------------------------------------- --------------------------------------* @create June 4:20:19 PM * @author Xuan Yu  

When testing, prepare several files (such as TXT format) that contain content in the myexample/01_file/folder

Then execute the CreateIndex () method, then execute the Searchfile () method, and finally watch the console output

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.