Lucene:(一)建立索引文件:2。建立索引文件(四)--Field信息的建立

Field信息:

DocumentWriter类中曾经描述,DocumentWriter类的一个功能是调用与

Field相关的类,写Field信息。写Field信息有两个类FieldInfos类和FieldWriter类,前者是用于写Field name信息,后者写Field value信息。

 

1.Field name信息:

Field name信息是用FieldInfo结构体表示,即FieldInfo表示一个Field

name信息。FieldInfos操作所有的FieldInfo,读和写操作,类似SegmentInfoSegmentInfos

   FieldInfo结构如下:

      String name;// The name of the field

      boolean isIndexed;// true if the field is indexed

      int number;

boolean storeTermVector;// true if the term vector should be stored

      // true if the term vector with offsets should be stored

boolean storeOffsetWithTermVector;      

//true if the term vector with positions should be stored

boolean storePositionWithTermVector;

// true if the norms for the indexed field should be omitted

boolean omitNorms;

  

   FieldInfos类和Field的关系可以看成SegmentInfosSegInfos的关系。但FieldInfos并不像SegmentInfos一样,继承自于Vector,而是包含了容器类型的变量。这里有两个容器,ArrayListHashMap,提供了按NameNumber两种存储。

   最终,FieldInfos写的文件(fnm)结构如下:

FieldInfos (.fnm)

 <ul>

<li>field的个数,int</li>

<li>field的名字,string类型<li>

<li>byte类型,记录该Field的相关信息,包括:

isIndexedstoreTermVectorstoreOffsetWithTermVector

storePositionWithTermVectoromitNorms

 每个信息用一个bit表示,1表示是,0表示否

</li>

</ul>

 

2.Field value信息:

FieldWriter类用于写FieldValue信息,这有两个文件fdx文件和fdt

文件。Fdx文件为域索引文件,记载相应的field在域值的指针;fdt则是域值信息。

   Fdx文件中文档n的域值信息就存在n*8的位置,格式如下:

Fdx:< FieldvaluesPosition > SegSize 

 

Fdt文件的格式如下:

Fdt:<   FieldCount, <FieldNum, Bits, value>FieldCount>DocCount

转载于:https://www.cnblogs.com/wanghoney/archive/2008/07/12/1241646.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值