Lucene 基本概念

来源:互联网 发布:大数据的基本概念 编辑:程序博客网 时间:2024/06/10 02:08

Classes used when indexing document with Lucene:

Document(Field Field Field Field Field...)-->Analyzer-->IndexWriter-->Directory


Core Indexing classes:

IndexWriter类: central component of the indexing process.

Directory类:the location of a Lucene index.

Analyzer类:extracting those tokens out of text that should be indexed and eliminating the rest.

Document类:a collection of fields.

Field类:each document in an index contains one or more named fields.



Core Searching classes:

IndexSearcher类: open an index in a read-only mode.

Directory dir = FSDirectory.open(new File("/tmp/index"));IndexSearcher searcher = new IndexSearcher(dir);Query q=new TermQuery(new Term("contents","lucene"));TopDocs hits = searcher.search(q,10);searcher.close();
Term类:

Query类:

TermQuery类:

TopDocs类: a simple container of pointers to the top N ranked search results--documents that match a given query.

0 0
原创粉丝点击