use of org.elasticsearch.index.mapper.DocumentMapperParser in project elasticsearch by elastic.
the class DocumentMapperParserTests method testFieldNameWithDots.
public void testFieldNameWithDots() 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").field("type", "keyword").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"));
assertNotNull(docMapper.objectMappers().get("foo"));
}
use of org.elasticsearch.index.mapper.DocumentMapperParser in project elasticsearch by elastic.
the class DocumentMapperParserTests method testTypeLevel.
public void testTypeLevel() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertThat(mapper.type(), equalTo("type"));
}
use of org.elasticsearch.index.mapper.DocumentMapperParser in project elasticsearch by elastic.
the class MultiFieldTests method testObjectFieldNotAllowed.
public void testObjectFieldNotAllowed() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field").field("type", "text").startObject("fields").startObject("multi").field("type", "object").endObject().endObject().endObject().endObject().endObject().endObject().string();
final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
try {
parser.parse("type", new CompressedXContent(mapping));
fail("expected mapping parse failure");
} catch (MapperParsingException e) {
assertTrue(e.getMessage().contains("cannot be used in multi field"));
}
}
use of org.elasticsearch.index.mapper.DocumentMapperParser in project elasticsearch by elastic.
the class MultiFieldTests method testNestedFieldNotAllowed.
public void testNestedFieldNotAllowed() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field").field("type", "text").startObject("fields").startObject("multi").field("type", "nested").endObject().endObject().endObject().endObject().endObject().endObject().string();
final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
try {
parser.parse("type", new CompressedXContent(mapping));
fail("expected mapping parse failure");
} catch (MapperParsingException e) {
assertTrue(e.getMessage().contains("cannot be used in multi field"));
}
}
use of org.elasticsearch.index.mapper.DocumentMapperParser in project elasticsearch by elastic.
the class IndexFieldMapperTests method testIndexNotConfigurable.
public void testIndexNotConfigurable() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_index").endObject().endObject().endObject().string();
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
MapperParsingException e = expectThrows(MapperParsingException.class, () -> parser.parse("type", new CompressedXContent(mapping)));
assertEquals("_index is not configurable", e.getMessage());
}
Aggregations