首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Lucene(2.4.1)技术研究(三)-Document源代码

2012-10-06 
Lucene(2.4.1)技术研究(3)--Document源代码1、Document文件Document是lucene自己定义的一种文件格式,lucene

Lucene(2.4.1)技术研究(3)--Document源代码
1、Document文件

Document是lucene自己定义的一种文件格式,lucene使用docement来代替对应的物理文件或者保存在数据库中的数据。因此Document只能作为数据源在Lucene中的数据存贮的一种文件形式。

Document只是负责收集数据源,因为不同的文件可以构建同一个Document。只要用户将不同的文件创建成Document类型的文件,Lucene就能快速找到查找并且使用他们。


对于一个Document文件,可以同时增加多个Field。Lucene中对于每个数据源是使用Field类来表示的。多个Field组成一个Document,多个Document组成一个索引文件。Document与Field关系如果一所示




此时,我们去看看Document这个类的源代码。Document采用默认不带参数的构造函数,但是我们他在创建的时间,
        产生两个变量:fields和 boost

其中fields是创建了一个arrayList,其主要是保存Field类

Boost主要是设置该doc的优先级

其方法:add(Fieldable field)增加一个field对象

    removeField(String name)  根据name移除一个ield对象(找到一个就返回)

removeFields(String name)  根据name移除所有的field对象

Field getField(String name)  根据名字找到该Field对象。

Fieldable getFieldable(String name)  根据名字找到Fieldable子类(Fieldable是 接口,具体有Filed来实现)

String get(String name) 根据名字,找到给Filed对象中包含的内容

public final byte[] getBinaryValue(String name) 主要查找Doc中包含有二进制field 数据(如果不存在,则返回null)
    public final List getFields() 直接返回该Doc中包含的Field。


<------------------我是快乐的转载符----------------------->

热点排行