本文整理汇总了Java中org.apache.lucene.document.FieldType.stored方法的典型用法代码示例。如果您正苦于以下问题:Java FieldType.stored方法的具体用法?Java FieldType.stored怎么用?Java FieldType.stored使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.document.FieldType
的用法示例。
在下文中一共展示了FieldType.stored方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newField
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public synchronized static Field newField(Random random, String name, String value, FieldType type) {
// Defeat any consumers that illegally rely on intern'd
// strings (we removed this from Lucene a while back):
name = new String(name);
FieldType prevType = fieldToType.get(name);
if (usually(random) || !type.indexed() || prevType != null) {
// most of the time, don't modify the params
if (prevType == null) {
fieldToType.put(name, new FieldType(type));
} else {
type = mergeTermVectorOptions(type, prevType);
}
return new Field(name, value, type);
}
// TODO: once all core & test codecs can index
// offsets, sometimes randomly turn on offsets if we are
// already indexing positions...
FieldType newType = new FieldType(type);
if (!newType.stored() && random.nextBoolean()) {
newType.setStored(true); // randomly store it
}
// Randomly turn on term vector options, but always do
// so consistently for the same field name:
if (!newType.storeTermVectors() && random.nextBoolean()) {
newType.setStoreTermVectors(true);
if (!newType.storeTermVectorPositions()) {
newType.setStoreTermVectorPositions(random.nextBoolean());
if (newType.storeTermVectorPositions()) {
if (!newType.storeTermVectorPayloads() && !OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
newType.setStoreTermVectorPayloads(random.nextBoolean());
}
}
}
if (!newType.storeTermVectorOffsets()) {
newType.setStoreTermVectorOffsets(random.nextBoolean());
}
if (VERBOSE) {
System.out.println("NOTE: LuceneTestCase: upgrade name=" + name + " type=" + newType);
}
}
newType.freeze();
fieldToType.put(name, newType);
// TODO: we need to do this, but smarter, ie, most of
// the time we set the same value for a given field but
// sometimes (rarely) we change it up:
/*
if (newType.omitNorms()) {
newType.setOmitNorms(random.nextBoolean());
}
*/
return new Field(name, value, newType);
}
示例2: _createStandardField
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <FIELD extends Field> FIELD _createStandardField(final IndexDocumentFieldID fieldId,
final IndexDocumentStandardFieldType type,
final FieldType fieldType) {
// guess the store condition from the fieldType
Field.Store store = fieldType != null ? fieldType.stored() ? Field.Store.YES
: Field.Store.NO
: null;
// Create the field by means of
// - store: the field has to be stored or not
// - fieldType: the field type
FIELD outField = null;
switch(type) {
case Double:
outField = fieldType == null ? (FIELD)(new DoubleField(fieldId.asString(),0D,store))
: (FIELD)(new DoubleField(fieldId.asString(),0D,fieldType));
break;
case Int:
outField = fieldType == null ? (FIELD)(new IntField(fieldId.asString(),0,store))
: (FIELD)(new IntField(fieldId.asString(),0,fieldType));
break;
case Long:
outField = fieldType == null ? (FIELD)(new LongField(fieldId.asString(),0L,store))
: (FIELD)(new LongField(fieldId.asString(),0L,fieldType));
break;
case Float:
outField = fieldType == null ? (FIELD)(new FloatField(fieldId.asString(),0F,store))
: (FIELD)(new FloatField(fieldId.asString(),0F,fieldType));
break;
case String:
outField = fieldType == null ? (FIELD)(new StringField(fieldId.asString(),"",store))
: (FIELD)(new Field(fieldId.asString(),"",fieldType));
break;
case Text:
outField = fieldType == null ? (FIELD)(new TextField(fieldId.asString(),new StringReader("")))
: (FIELD)(new Field(fieldId.asString(),new StringReader(""),fieldType));
break;
default:
throw new IllegalArgumentException(fieldType + "is NOT a supported type");
}
return outField;
}