Lucene深入研究(3)

<!-- -->

Package org.apache.lucene.document Description

The logical representation of a Document for indexing and searching.

The document package provides the user level logical representation of content to be indexed and searched. The package also provides utilities for working with Documents and Fieldables.

Document and Fieldable

A Document is a collection of Fieldables. A Fieldable is a logical representation of a user's content that needs to be indexed or stored. Fieldables have a number of properties that tell Lucene how to treat the content (like indexed, tokenized, stored, etc.) See the Field implementation of Fieldable for specifics on these properties.

Note: it is common to refer to Documents having Fields, even though technically they have Fieldables.

Working with Documents

First and foremost, a Document is something created by the user application. It is your job to create Documents based on the content of the files you are working with in your application (Word, txt, PDF, Excel or any other format.) How this is done is completely up to you. That being said, there are many tools available in other projects that can make the process of taking a file and converting it into a Lucene Document. To see an example of this, take a look at the Lucene demo and the associated source code for extracting content from HTML.

The DateTools and NumberTools classes are utility classes to make dates, times and longs searchable (remember, Lucene only searches text).

The FieldSelector class provides a mechanism to tell Lucene how to load Documents from storage. If no FieldSelector is used, all Fieldables on a Document will be loaded. As an example of the FieldSelector usage, consider the common use case of displaying search results on a web page and then having users click through to see the full document. In this scenario, it is often the case that there are many small fields and one or two large fields (containing the contents of the original file). Before the FieldSelector, the full Document had to be loaded, including the large fields, in order to display the results. Now, using the FieldSelector, one can FieldSelectorResult.LAZY_LOAD the large fields, thus only loading the large fields when a user clicks on the actual link to view the original content.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Lucene是一个高性能、可伸缩的信息搜索(IR)库。目前最新版本是4.3.1. 它可以为你的应用程序添加索引和搜索能力。Lucene是用java实现的、成熟的开源项目,是著名的Apache Jakarta大家庭的一员,并且基于Apache软件许可 [ASF, License]。同样,Lucene是当前非常流行的、免费的Java信息搜索(IR)库。 面对已经存在的商业全文检索引擎,Lucene也具有相当的优势 ,后,转移到apache软件基金会后,借助于apache软件基金会的网络平台,程序员可以方便的和开发者、其它程序员交流,促成资源的共享,甚至直接获得已经编写完备的扩充功能。最后,虽然Lucene使用Java语言写成,但是开放源代码社区的程序员正在不懈的将之使用各种传统语言实现(例如.net framework[14]),在遵守Lucene索引文件格式的基础上,使得Lucene能够运行在各种各样的平台上,系统管理员可以根据当前的平台适合的语言来合理的选择。 本课程由浅入深的介绍了Lucene4的发展历史,开发环境搭建,分析lucene4的中文分词原理,深入讲了lucenne4的系统架构,分析lucene4索引实现原理及性能优化,了解关于lucene4的搜索算法优化及利用java结合lucene4实现类百度文库的全文检索功能等相对高端实用的内容,市面上一般很难找到同类具有相同深度与广度的视频,集原理、基础、案例与实战与一身,不可多得的一部高端视频教程。 关健字:Lucene、全文搜索、中文分词、全文检索引擎 、文本分析、网页爬虫、网络小偷

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值