Java 类org.apache.lucene.index.IndexableFieldType 实例源码

项目:elasticsearch_my    文件:KeywordFieldMapperTests.java   
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());
}
项目:elasticsearch_my    文件:KeywordFieldMapperTests.java   
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());
}
项目:elasticsearch_my    文件:TextFieldMapperTests.java   
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());
}
项目:lucure-core    文件:IndexableFieldUtils.java   
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;
}
项目:meresco-lucene    文件:DocumentStringToDocumentTest.java   
@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());
}
项目:meresco-lucene    文件:DocumentStringToDocumentTest.java   
@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());
}
项目:elasticsearch_my    文件:CustomDocValuesField.java   
@Override
public IndexableFieldType fieldType() {
    return TYPE;
}
项目:Elasticsearch    文件:NumberFieldMapper.java   
@Override
public IndexableFieldType fieldType() {
    return TYPE;
}
项目:search    文件:LazyDocument.java   
@Override
public IndexableFieldType fieldType() {
  return getRealValue().fieldType();
}
项目:elasticsearch-minhash    文件:MinHashFieldMapper.java   
@Override
public IndexableFieldType fieldType() {
    return TYPE;
}
项目:NYBC    文件:LazyDocument.java   
@Override
public IndexableFieldType fieldType() {
  return getRealValue().fieldType();
}
项目:BioSolr    文件:MergeAbstractFieldType.java   
private ObjectField(String name, Object object, IndexableFieldType type, float boost) {
  this.name = name;
  this.object = object;
  this.type = type;
  this.boost = boost;
}
项目:BioSolr    文件:MergeAbstractFieldType.java   
@Override
public IndexableFieldType fieldType() {
  return type;
}
项目:read-open-source-code    文件:LazyDocument.java   
@Override
public IndexableFieldType fieldType() {
  return getRealValue().fieldType();
}
项目:read-open-source-code    文件:LazyDocument.java   
@Override
public IndexableFieldType fieldType() {
  return getRealValue().fieldType();
}
项目:read-open-source-code    文件:LazyDocument.java   
@Override
public IndexableFieldType fieldType() {
  return getRealValue().fieldType();
}
项目:Maskana-Gestor-de-Conocimiento    文件:LazyDocument.java   
@Override
public IndexableFieldType fieldType() {
  return getRealValue().fieldType();
}