最近在做搜索,抽空看一下lucene,资料挺多的,不过大部分都是3.x了……在对着官方文档大概看一下。
优化后的lucene索引文件(4.9.0)

一、段文件
1.段文件:segments_5p和segments.gen。
segments.gen保存当前段文件版本信息。
- segments.gen: GenHeader, Generation, Generation, Footer
segments_N(segments_5p)保存最新的段的信息,包括段的个数,每个段的段名、文档数等信息。
-
segments_N: Header, Version, NameCounter, SegCount,
SegCount, CommitUserData, Footer
源码参考:SegmentInfos.read(Directory directory, String segmentFileName):
2.段信息:*.si,存储段的基本信息。
- .si: Header, SegVersion, SegSize, IsCompoundFile, Diagnostics, Attributes, Files
只对4.0-4.5使用,新版已经抛弃了,可以无视。
二、域文件
1.域(field):*.fnm ,存储域的信息。
-
FieldInfos (.fnm) –> Header,FieldsCount,
FieldsCount,Footer
源码参考:org.apache.lucene.codecs.lucene46.Lucene46FieldInfosFormat
2.域(field)索引:*.fdx,存储到域数据的指针。
-
FieldsIndex (.fdx) –>
,
源码参考:org.apache.lucene.codecs.lucene41.Lucene41StoredFieldsFormat
3.域(field)数据:*.fdt,存储文档的域,话说这个结构比较复杂,简单列一下。
-
FieldData (.fdt) –>
, PackedIntsVersion, ChunkCount - ChunkCount is not known in advance and is the number of chunks necessary to store all document of the segment
-
Chunk –> DocBase, ChunkDocs, DocFieldCounts, DocLengths,
源码参考:org.apache.lucene.codecs.lucene41.Lucene41StoredFieldsFormat
三、字典文件
4.项(term)字典:*.tim,存储项的信息。
- TermsDict (.tim) –> Header, PostingsHeader, NodeBlockNumBlocks, FieldSummary, DirOffset, Footer
源码参考:org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat
5.项(term)索引:*.tip,到项字典的索引。
-
TermsIndex (.tip) –> Header, FSTIndexNumFields
NumFields, DirOffset, Footer
源码参考:org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat
四、其他文件
6.频率:*.doc,包括一个文档列表,列表中每一个项都有一个频数。
-
docFile(.doc) –> Header,
TermCount, Footer
源码参考:org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat
7.位置:*.pos,存储项在索引中出现的位置信息。
-
PosFile(.pos) –> Header,
TermCount, Footer
源码参考:org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat
8.norm文件:.nvd,.nvm,编码文档和域的长度已经boost factors。
-
Norms data (.nvd) –> Header,
NumFields,Footer
源码参考:org.apache.lucene.codecs.lucene49.Lucene49NormsFormat
除此之外,还可能有一些其他文件,暂且不表。
参考:
http://lucene.apache.org/core/4_9_0/core/org/apache/lucene/codecs/lucene49/package-summary.html#File_Naming
http://www.cnblogs.com/forfuture1978/category/300665.html
Last modified on 2015-02-04