lucene fnm文件 结构
一。.fnm文件
存储field名字和field属性
文件结构:
分为三部分。这三部分构成一个field。
1.field名字的长度 类型16进制一位。
2.field名字 类型String
3.field属性:下面属性做或操作。构成一个一位16进制数 例如:IS_INDEXED并且STORE_TERMVECTOR =0x1|0x2=0000001|00000010=00000011=0x3
IS_INDEXED = 0x1;
STORE_TERMVECTOR = 0x2;
STORE_POSITIONS_WITH_TERMVECTOR = 0x4;
STORE_OFFSET_WITH_TERMVECTOR = 0x8;
OMIT_NORMS = 0x10;
STORE_PAYLOADS = 0x20;
OMIT_TF = 0x40;
代码如下:FieldInfos.java
output.writeVInt(size());//写入filed名字大小
for (int i = 0; i < size(); i++) {//组装field属性
FieldInfo fi = fieldInfo(i);
byte bits = 0x0;
if (fi.isIndexed) bits |= IS_INDEXED;
if (fi.storeTermVector) bits |= STORE_TERMVECTOR;
if (fi.storePositionWithTermVector) bits |= STORE_POSITIONS_WITH_TERMVECTOR;
if (fi.storeOffsetWithTermVector) bits |= STORE_OFFSET_WITH_TERMVECTOR;
if (fi.omitNorms) bits |= OMIT_NORMS;
if (fi.storePayloads) bits |= STORE_PAYLOADS;
if (fi.omitTf) bits |= OMIT_TF;
output.writeString(fi.name);//写入filed名字
output.writeByte(bits);//写入field属性