use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch by elastic.
the class DocumentMapperParserTests method testFieldNameWithDeepDots.
public void testFieldNameWithDeepDots() throws Exception {
IndexService indexService = createIndex("test");
DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("foo.bar").field("type", "text").endObject().startObject("foo.baz").startObject("properties").startObject("deep.field").field("type", "keyword").endObject().endObject().endObject().endObject().endObject().endObject().string();
DocumentMapper docMapper = mapperParser.parse("type", new CompressedXContent(mapping));
assertNotNull(docMapper.mappers().getMapper("foo.bar"));
assertNotNull(docMapper.mappers().getMapper("foo.baz.deep.field"));
assertNotNull(docMapper.objectMappers().get("foo"));
}
use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch by elastic.
the class Murmur3FieldMapperTests method testDefaults.
public void testDefaults() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("field").field("type", "murmur3").endObject().endObject().endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
ParsedDocument parsedDoc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder().startObject().field("field", "value").endObject().bytes());
IndexableField[] fields = parsedDoc.rootDoc().getFields("field");
assertNotNull(fields);
assertEquals(Arrays.toString(fields), 1, fields.length);
IndexableField field = fields[0];
assertEquals(IndexOptions.NONE, field.fieldType().indexOptions());
assertEquals(DocValuesType.SORTED_NUMERIC, field.fieldType().docValuesType());
}
use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch by elastic.
the class SizeMappingTests method testSizeNotSet.
public void testSizeNotSet() throws Exception {
IndexService service = createIndex("test", Settings.EMPTY, "type");
DocumentMapper docMapper = service.mapperService().documentMapper("type");
BytesReference source = XContentFactory.jsonBuilder().startObject().field("field", "value").endObject().bytes();
ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", source, XContentType.JSON));
assertThat(doc.rootDoc().getField("_size"), nullValue());
}
use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch by elastic.
the class SizeMappingTests method testSizeDisabled.
public void testSizeDisabled() throws Exception {
IndexService service = createIndex("test", Settings.EMPTY, "type", "_size", "enabled=false");
DocumentMapper docMapper = service.mapperService().documentMapper("type");
BytesReference source = XContentFactory.jsonBuilder().startObject().field("field", "value").endObject().bytes();
ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", source, XContentType.JSON));
assertThat(doc.rootDoc().getField("_size"), nullValue());
}
use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch-opennlp-plugin by spinscale.
the class OpenNlpMappingTest method testAnalyzedOpenNlpFieldMappings.
@Test
public void testAnalyzedOpenNlpFieldMappings() throws IOException {
String mapping = copyToStringFromClasspath("/test-mapping-keywordanalyzer.json");
DocumentMapper docMapper = mapperParser.parse(mapping);
String message = String.format("\"name\":{\"type\":\"string\",\"analyzer\":\"keyword\"}");
assertThat(docMapper.mappingSource().string(), containsString(message));
}
Aggregations