本文整理汇总了Java中org.apache.lucene.index.IndexableFieldType类的典型用法代码示例。如果您正苦于以下问题:Java IndexableFieldType类的具体用法?Java IndexableFieldType怎么用?Java IndexableFieldType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndexableFieldType类属于org.apache.lucene.index包,在下文中一共展示了IndexableFieldType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fieldType
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
@Override
public IndexableFieldType fieldType() {
return TYPE;
}
示例2: testTextFieldWithTermVectors
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
@Test
public void testTextFieldWithTermVectors() {
JsonArray json = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("type", "TextField")
.add("termVectors", JsonValue.TRUE)
.add("name", "name")
.add("value", "value"))
.build();
Document result = convert(json.toString());
IndexableFieldType fieldType = result.getField("name").fieldType();
assertTrue(fieldType.storeTermVectors());
assertEquals("value", result.getField("name").stringValue());
}
示例3: testDefaults
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
public void testDefaults() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "keyword").endObject().endObject()
.endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, mapper.mappingSource().toString());
ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("field", "1234")
.endObject()
.bytes());
IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(2, fields.length);
assertEquals(new BytesRef("1234"), fields[0].binaryValue());
IndexableFieldType fieldType = fields[0].fieldType();
assertThat(fieldType.omitNorms(), equalTo(true));
assertFalse(fieldType.tokenized());
assertFalse(fieldType.stored());
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.DOCS));
assertThat(fieldType.storeTermVectors(), equalTo(false));
assertThat(fieldType.storeTermVectorOffsets(), equalTo(false));
assertThat(fieldType.storeTermVectorPositions(), equalTo(false));
assertThat(fieldType.storeTermVectorPayloads(), equalTo(false));
assertEquals(DocValuesType.NONE, fieldType.docValuesType());
assertEquals(new BytesRef("1234"), fields[1].binaryValue());
fieldType = fields[1].fieldType();
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.NONE));
assertEquals(DocValuesType.SORTED_SET, fieldType.docValuesType());
}
示例4: testNormalizer
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
public void testNormalizer() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field")
.field("type", "keyword").field("normalizer", "my_lowercase").endObject().endObject()
.endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, mapper.mappingSource().toString());
ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("field", "AbC")
.endObject()
.bytes());
IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(2, fields.length);
assertEquals(new BytesRef("abc"), fields[0].binaryValue());
IndexableFieldType fieldType = fields[0].fieldType();
assertThat(fieldType.omitNorms(), equalTo(true));
assertFalse(fieldType.tokenized());
assertFalse(fieldType.stored());
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.DOCS));
assertThat(fieldType.storeTermVectors(), equalTo(false));
assertThat(fieldType.storeTermVectorOffsets(), equalTo(false));
assertThat(fieldType.storeTermVectorPositions(), equalTo(false));
assertThat(fieldType.storeTermVectorPayloads(), equalTo(false));
assertEquals(DocValuesType.NONE, fieldType.docValuesType());
assertEquals(new BytesRef("abc"), fields[1].binaryValue());
fieldType = fields[1].fieldType();
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.NONE));
assertEquals(DocValuesType.SORTED_SET, fieldType.docValuesType());
}
示例5: testDefaults
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
public void testDefaults() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "text").endObject().endObject()
.endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, mapper.mappingSource().toString());
ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("field", "1234")
.endObject()
.bytes());
IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(1, fields.length);
assertEquals("1234", fields[0].stringValue());
IndexableFieldType fieldType = fields[0].fieldType();
assertThat(fieldType.omitNorms(), equalTo(false));
assertTrue(fieldType.tokenized());
assertFalse(fieldType.stored());
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS));
assertThat(fieldType.storeTermVectors(), equalTo(false));
assertThat(fieldType.storeTermVectorOffsets(), equalTo(false));
assertThat(fieldType.storeTermVectorPositions(), equalTo(false));
assertThat(fieldType.storeTermVectorPayloads(), equalTo(false));
assertEquals(DocValuesType.NONE, fieldType.docValuesType());
}
示例6: fieldType
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
@Override
public IndexableFieldType fieldType() {
return getRealValue().fieldType();
}
示例7: from
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
public static FieldType from(IndexableFieldType indexableFieldType) {
final FieldType fieldType = new FieldType();
fieldType.setStored(indexableFieldType.stored());
fieldType.setIndexed(indexableFieldType.indexed());
fieldType.setIndexOptions(indexableFieldType.indexOptions());
fieldType.setStoreTermVectors(indexableFieldType.storeTermVectors());
fieldType.setStoreTermVectorPositions(indexableFieldType.storeTermVectorPositions());
fieldType.setStoreTermVectorPayloads(indexableFieldType.storeTermVectorPayloads());
fieldType.setStoreTermVectorOffsets(indexableFieldType.storeTermVectorOffsets());
fieldType.setDocValueType(indexableFieldType.docValueType());
fieldType.setOmitNorms(indexableFieldType.omitNorms());
fieldType.setTokenized(indexableFieldType.tokenized());
return fieldType;
}
示例8: ObjectField
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
private ObjectField(String name, Object object, IndexableFieldType type, float boost) {
this.name = name;
this.object = object;
this.type = type;
this.boost = boost;
}
示例9: fieldType
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
@Override
public IndexableFieldType fieldType() {
return type;
}
示例10: testTextField
import org.apache.lucene.index.IndexableFieldType; //导入依赖的package包/类
@Test
public void testTextField() {
JsonArray json = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("type", "TextField")
.add("name", "name")
.add("value", "value"))
.build();
Document result = convert(json.toString());
IndexableFieldType fieldType = result.getField("name").fieldType();
assertEquals(TextField.TYPE_NOT_STORED, fieldType);
assertFalse(fieldType.storeTermVectors());
assertEquals("value", result.getField("name").stringValue());
}