The remaining files are all per-segment, and are thus defined by suffix. Fields | Field Info
Field names are stored in the field info file, with suffix .fnm. FieldInfos (.fnm) --> FieldsCount, <FieldName, FieldBits>FieldsCount FieldsCount --> VInt FieldName --> String FieldBits --> Byte The low-order bit is one for indexed fields, and zero for non-indexed fields. The second lowest-order bit is one for fields that have term vectors stored, and zero for fields without term vectors. Fields are numbered by their order in this file. Thus field zero is the first field in the file, field one the next, and so on. Note that, like document numbers, field numbers are segment relative. Stored Fields
Stored fields are represented by two files: The field index, or .fdx file. This contains, for each document, a pointer to its field data, as follows: FieldIndex (.fdx) --> <FieldValuesPosition>SegSize FieldValuesPosition --> Uint64 This is used to find the location within the field data file of the fields of a particular document. Because it contains fixed-length data, this file may be easily randomly accessed. The position of document n‘s field data is the Uint64 at n*8 in this file. The field data, or .fdt file. This contains the stored fields of each document, as follows: FieldData (.fdt) --> <DocFieldData>SegSize DocFieldData --> FieldCount, <FieldNum, Bits, Value>FieldCount FieldCount --> VInt FieldNum --> VInt Lucene <= 1.4: Bits --> Byte Value --> String Only the low-order bit of Bits is used. It is one for tokenized fields, and zero for non-tokenized fields. Lucene >= 1.9: Bits --> Byte - low order bit is one for tokenized fields
- second bit is one for fields containing binary data
- third bit is one for fields with compression option enabled (if compression is enabled, the algorithm used is ZLIB)
Value --> String | BinaryValue (depending on Bits) BinaryValue --> ValueSize, <Byte>^ValueSize ValueSize --> VInt
|
|
Term Dictionary | The term dictionary is represented as two files: The term infos, or tis file. TermInfoFile (.tis)--> TIVersion, TermCount, IndexInterval, SkipInterval, TermInfos TIVersion --> UInt32 TermCount --> UInt64 IndexInterval --> UInt32 SkipInterval --> UInt32 TermInfos --> <TermInfo>TermCount TermInfo --> <Term, DocFreq, FreqDelta, ProxDelta, SkipDelta> Term --> <PrefixLength, Suffix, FieldNum> Suffix --> String PrefixLength, DocFreq, FreqDelta, ProxDelta, SkipDelta --> VInt This file is sorted by Term. Terms are ordered first lexicographically by the term‘s field name, and within that lexicographically by the term‘s text. TIVersion names the version of the format of this file and is -2 in Lucene 1.4. Term text prefixes are shared. The PrefixLength is the number of initial characters from the previous term which must be pre-pended to a term‘s suffix in order to form the term‘s text. Thus, if the previous term‘s text was "bone" and the term is "boy", the PrefixLength is two and the suffix is "y". FieldNumber determines the term‘s field, whose name is stored in the .fdt file. DocFreq is the count of documents which contain the term. FreqDelta determines the position of this term‘s TermFreqs within the .frq file. In particular, it is the difference between the position of this term‘s data in that file and the position of the previous term‘s data (or zero, for the first term in the file). ProxDelta determines the position of this term‘s TermPositions within the .prx file. In particular, it is the difference between the position of this term‘s data in that file and the position of the previous term‘s data (or zero, for the first term in the file. SkipDelta determines the position of this term‘s SkipData within the .frq file. In particular, it is the number of bytes after TermFreqs that the SkipData starts. In other words, it is the length of the TermFreq data. The term info index, or .tii file. This contains every IndexIntervalth entry from the .tis file, along with its location in the "tis" file. This is designed to be read entirely into memory and used to provide random access to the "tis" file. The structure of this file is very similar to the .tis file, with the addition of one item per record, the IndexDelta. TermInfoIndex (.tii)--> TIVersion, IndexTermCount, IndexInterval, SkipInterval, TermIndices TIVersion --> UInt32 IndexTermCount --> UInt64 IndexInterval --> UInt32 SkipInterval --> UInt32 TermIndices --> <TermInfo, IndexDelta>IndexTermCount IndexDelta --> VLong IndexDelta determines the position of this term‘s TermInfo within the .tis file. In particular, it is the difference between the position of this term‘s entry in that file and the position of the previous term‘s entry. TODO: document skipInterval information
|
|
Frequencies | The .frq file contains the lists of documents which contain each term, along with the frequency of the term in that document. FreqFile (.frq) --> <TermFreqs, SkipData>TermCount TermFreqs --> <TermFreq>DocFreq TermFreq --> DocDelta, Freq? SkipData --> <SkipDatum>DocFreq/SkipInterval SkipDatum --> DocSkip,FreqSkip,ProxSkip DocDelta,Freq,DocSkip,FreqSkip,ProxSkip --> VInt TermFreqs are ordered by term (the term is implicit, from the .tis file). TermFreq entries are ordered by increasing document number. DocDelta determines both the document number and the frequency. In particular, DocDelta/2 is the difference between this document number and the previous document number (or zero when this is the first document in a TermFreqs). When DocDelta is odd, the frequency is one. When DocDelta is even, the frequency is read as another VInt. For example, the TermFreqs for a term which occurs once in document seven and three times in document eleven would be the following sequence of VInts: 15, 22, 3 DocSkip records the document number before every SkipIntervalth document in TermFreqs. Document numbers are represented as differences from the previous value in the sequence. FreqSkip and ProxSkip record the position of every SkipIntervalth entry in FreqFile and ProxFile, respectively. File positions are relative to the start of TermFreqs and Positions, to the previous SkipDatum in the sequence. For example, if DocFreq=35 and SkipInterval=16, then there are two SkipData entries, containing the 15th and 31st document numbers in TermFreqs. The first FreqSkip names the number of bytes after the beginning of TermFreqs that the 16th SkipDatum starts, and the second the number of bytes after that that the 32nd starts. The first ProxSkip names the number of bytes after the beginning of Positions that the 16th SkipDatum starts, and the second the number of bytes after that that the 32nd starts.
|
|
Positions | The .prx file contains the lists of positions that each term occurs at within documents. ProxFile (.prx) --> <TermPositions>TermCount TermPositions --> <Positions>DocFreq Positions --> <PositionDelta>Freq PositionDelta --> VInt TermPositions are ordered by term (the term is implicit, from the .tis file). Positions entries are ordered by increasing document number (the document number is implicit from the .frq file). PositionDelta is the difference between the position of the current occurrence in the document and the previous occurrence (or zero, if this is the first occurrence in this document). For example, the TermPositions for a term which occurs as the fourth term in one document, and as the fifth and ninth term in a subsequent document, would be the following sequence of VInts: 4, 5, 4
|
|
Normalization Factors | There‘s a norm file for each indexed field with a byte for each document. The .f[0-9]* file contains, for each document, a byte that encodes a value that is multiplied into the score for hits on that field: Norms (.f[0-9]*) --> <Byte>SegSize Each byte encodes a floating point value. Bits 0-2 contain the 3-bit mantissa, and bits 3-8 contain the 5-bit exponent. These are converted to an IEEE single float value as follows: If the byte is zero, use a zero float. Otherwise, set the sign bit of the float to zero; add 48 to the exponent and use this as the float‘s exponent; map the mantissa to the high-order 3 bits of the float‘s mantissa; and set the low-order 21 bits of the float‘s mantissa to zero.
|
|
Term Vectors | The Document Index or .tvx file. This contains, for each document, a pointer to the document data in the Document (.tvd) file. DocumentIndex (.tvx) --> TVXVersion<DocumentPosition>NumDocs TVXVersion --> Int DocumentPosition --> UInt64 This is used to find the position of the Document in the .tvd file. The Document or .tvd file. This contains, for each document, the number of fields, a list of the fields with term vector info and finally a list of pointers to the field information in the .tvf (Term Vector Fields) file. Document (.tvd) --> TVDVersion<NumFields, FieldNums, FieldPositions,>NumDocs TVDVersion --> Int NumFields --> VInt FieldNums --> <FieldNumDelta>NumFields FieldNumDelta --> VInt FieldPositions --> <FieldPosition>NumFields FieldPosition --> VLong The .tvd file is used to map out the fields that have term vectors stored and where the field information is in the .tvf file. The Field or .tvf file. This file contains, for each field that has a term vector stored, a list of the terms and their frequencies. Field (.tvf) --> TVFVersion<NumTerms, NumDistinct, TermFreqs>NumFields TVFVersion --> Int NumTerms --> VInt NumDistinct --> VInt -- Future Use TermFreqs --> <TermText, TermFreq>NumTerms TermText --> <PrefixLength, Suffix> PrefixLength --> VInt Suffix --> String TermFreq --> VInt Term text prefixes are shared. The PrefixLength is the number of initial characters from the previous term which must be pre-pended to a term‘s suffix in order to form the term‘s text. Thus, if the previous term‘s text was "bone" and the term is "boy", the PrefixLength is two and the suffix is "y".
|
|
Deleted Documents | The .del file is optional, and only exists when a segment contains deletions: Deletions (.del) --> ByteCount,BitCount,Bits ByteSize,BitCount --> Uint32 Bits --> <Byte>ByteCount ByteCount indicates the number of bytes in Bits. It is typically (SegSize/8)+1. BitCount indicates the number of bits that are currently set in Bits. Bits contains one bit for each document indexed. When the bit corresponding to a document number is set, that document is marked as deleted. Bit ordering is from least to most significant. Thus, if Bits contains two bytes, 0x00 and 0x02, then document 9 is marked as deleted.
|
|
|