/*以前一直不了解boost为何?其实boost就是由于后来进行相关度排序时用的,由于在query时,
*每个term都分属与一个field。同样的term当其属于不同的field时,其重要性不一样,譬如
*field:<title>中的term就要比field:<content>中的term重要!而这个重要性如何体现就
*可以通过boost进行设定。可以把field:<title>的boost至设大一些
*注意boost在Document中还有整个的设定.
*/
private float boost = 1.0f;
public void setBoost(float boost) {this.boost = boost;}
public float getBoost() { return boost;}
public static final Field Keyword(String name, String value) {return new Field(name, value, true, true, false);}
public static final Field UnIndexed(String name, String value) {return new Field(name, value, true, false, false);}
public static final Field Text(String name, String value) {return Text(name, value, false);}
public static final Field Keyword(String name, Date value) {return new Field(name, DateField.dateToString(value), true, true, false);}
public static final Field Text(String name, String value, boolean storeTermVector) {
return new Field(name, value, true, true, true, storeTermVector);}
public static final Field UnStored(String name, String value) {
return UnStored(name, value, false);}
public static final Field UnStored(String name, String value, boolean storeTermVector) {
return new Field(name, value, false, true, true, storeTermVector); }
public static final Field Text(String name, Reader value) {
return Text(name, value, false);}
public static final Field Text(String name, Reader value, boolean storeTermVector) {
Field f = new Field(name, value);
f.storeTermVector = storeTermVector;
return f;
}
public String name() { return name; }
public String stringValue() { return stringValue; }
public Reader readerValue() { return readerValue; }
public Field(String name, String string,
boolean store, boolean index, boolean token) {
this(name, string, store, index, token, false);
}
//最低层的构造函数
public Field(String name, String string,
boolean store, boolean index, boolean token, boolean storeTermVector)
Field(String name, Reader reader)
public final boolean isStored() { return isStored; }
public final boolean isIndexed() { return isIndexed; }
public final boolean isTokenized() { return isTokenized; }
public final boolean isTermVectorStored() { return storeTermVector; }
public final String toString()
public final String toString2()//我加的用来返回六元组
}Field的六元组形式为<name,stringValue,isStored,isIndexed,isTokenized,isTermVectorStored>,Field提供了不同的构造函数
主要有一下几个
总的来看,Field的构造函数就只有四种形式,Text,KeyWord,UnIndexed,UnStored,只不过每种函数往往有多种变形罢了.
*每个term都分属与一个field。同样的term当其属于不同的field时,其重要性不一样,譬如
*field:<title>中的term就要比field:<content>中的term重要!而这个重要性如何体现就
*可以通过boost进行设定。可以把field:<title>的boost至设大一些
*注意boost在Document中还有整个的设定.
*/
private float boost = 1.0f;
public void setBoost(float boost) {this.boost = boost;}
public float getBoost() { return boost;}
public static final Field Keyword(String name, String value) {return new Field(name, value, true, true, false);}
public static final Field UnIndexed(String name, String value) {return new Field(name, value, true, false, false);}
public static final Field Text(String name, String value) {return Text(name, value, false);}
public static final Field Keyword(String name, Date value) {return new Field(name, DateField.dateToString(value), true, true, false);}
public static final Field Text(String name, String value, boolean storeTermVector) {
return new Field(name, value, true, true, true, storeTermVector);}
public static final Field UnStored(String name, String value) {
return UnStored(name, value, false);}
public static final Field UnStored(String name, String value, boolean storeTermVector) {
return new Field(name, value, false, true, true, storeTermVector); }
public static final Field Text(String name, Reader value) {
return Text(name, value, false);}
public static final Field Text(String name, Reader value, boolean storeTermVector) {
Field f = new Field(name, value);
f.storeTermVector = storeTermVector;
return f;
}
public String name() { return name; }
public String stringValue() { return stringValue; }
public Reader readerValue() { return readerValue; }
public Field(String name, String string,
boolean store, boolean index, boolean token) {
this(name, string, store, index, token, false);
}
//最低层的构造函数
public Field(String name, String string,
boolean store, boolean index, boolean token, boolean storeTermVector)
Field(String name, Reader reader)
public final boolean isStored() { return isStored; }
public final boolean isIndexed() { return isIndexed; }
public final boolean isTokenized() { return isTokenized; }
public final boolean isTermVectorStored() { return storeTermVector; }
public final String toString()
public final String toString2()//我加的用来返回六元组
}Field的六元组形式为<name,stringValue,isStored,isIndexed,isTokenized,isTermVectorStored>,Field提供了不同的构造函数
主要有一下几个
方法 | 切词 | 索引 | 存储 | 用途 |
Field.Text(String name, String value) | Yes | Yes | Yes | 切分,索引,并存储,比如:title,subject |
Field Text(String name, Reader value) | Yes | Yes | Yes | 与上面同, Term Vector并不存储此Field |
Field Text(String name, String value, boolean storeTermVector) | Yes | Yes | Yes | 切分,索引,存储,比如:title,subject.于上面不同的加入了一个控制变量 |
Field Text(String name, Reader value, boolean storeTermVector) | Yes | Yes | Yes | 切分,索引,存储,比如:title,subject.于上面不同的加入了一个控制变量 |
Field.Keyword(String name, String value) | No | Yes | Yes | 不切分,索引,存储,比如:date,url |
Field Keyword(String name, Date value) | 不切分,存储,索引,用来返回hits | |||
Field.UnIndexed(String name, String value) | No | No | Yes | 不切分,不索引,存储,比如:文件路径 |
Field.UnStored(String name, String value) | Yes | Yes | No | 只全文索引,不存储 |
Field UnStored(String name, String value, boolean storeTermVector) | Yes | Yes | No | 于上面相同,不同的是加入了一个控制变量 |