dinghao

记录成长点滴

 

理解Lucene(一)

1、什么是lucene

People new to Lucene often mistake it for a ready-to-use application like a

file-search program, a web crawler, or a web site search engine. That isn’t what

Lucene is: Lucene is a software library, a toolkit if you will, not a full-featured

search application. It concerns itself with text indexing and searching, and it

does those things very well. Lucene lets your application deal with business rules

specific to its problem domain while hiding the complexity of indexing and

searching implementation behind a simple-to-use API. You can think of Lucene

as a layer that applications sit on top of,正如下图所示

 

Figure 1.5 A typical application integration with Lucene

2Lucene能做什么?

Lucene allows you to add indexing and searching capabilities to your applications

(these functions are described in section 1.3). Lucene can index and make searchable

any data that can be converted to a textual format.

This means you can use Lucene to index and

search data stored in files: web pages on remote web servers, documents stored in

local file systems, simple text files, Microsoft Word documents, HTML or PDF

files, or any other format from which you can extract textual information.

3、什么是IndexingIndex

This is where indexing comes in: To search large amounts of text

quickly, you must first index that text and convert it into a format that will let you

search it rapidly, eliminating the slow sequential scanning process. This conversion

process is called indexing, and its output is called an index.

具体到LuceneIndex的含义:

You can think of an index as a data structure that allows fast random access to

words stored inside it. The concept behind it is analogous to an index at the end

of a book, which lets you quickly locate pages that discuss certain topics. In the

case of Lucene, an index is a specially designed data structure, typically stored

on the file system as a set of index files.

appendix B,Index file的结构说明

4、什么是Searching

Searching is the process of looking up words in an index to find documents where

they appear

Searching的品质由PricisionRecall描述。

Recall measures how well the search system finds relevant documents,

whereas precision measures how well the system filters out the irrelevant

documents.

评价Searching的其他因素:

We already mentioned speed and the ability to quickly

search large quantities of text. Support for single and multiterm queries, phrase

queries, wildcards, result ranking, and sorting are also important, as is a friendly

syntax for entering those queries.

5、简单的例子:搜索一个目录树中的txt,很小的例子,但可以对Lucene的整体有个了解,略

通过例子可以看出Lucene和具体业务是分开的,它只用到了很少的LuceneApi

6、注意:

Note that the Hits object contains only references to the underlying documents.

In other words, instead of being loaded immediately upon search, matches are

loaded from the index in a lazy fashion—only when requested with the hits.

doc(int) call.

Hits只是包含documents的索引,匹配项从索引加载到Search是延迟加载的――仅当调用

Hits.doc()

posted on 2006-07-31 14:45  思无邪  阅读(551)  评论(2编辑  收藏  举报

导航