use of org.elasticsearch.common.bytes.BytesReference in project elasticsearch by elastic.
the class DocumentParserTests method testDynamicFalseDottedFieldNameLongArray.
public void testDynamicFalseDottedFieldNameLongArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false").endObject().endObject().string();
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
BytesReference bytes = XContentFactory.jsonBuilder().startObject().startArray("foo.bar.baz").value(0).value(1).endArray().endObject().bytes();
ParsedDocument doc = mapper.parse("test", "type", "1", bytes);
assertEquals(0, doc.rootDoc().getFields("foo.bar.baz").length);
}
use of org.elasticsearch.common.bytes.BytesReference in project elasticsearch by elastic.
the class DocumentParserTests method testDynamicLongArrayWithTemplate.
public void testDynamicLongArrayWithTemplate() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startArray("dynamic_templates").startObject().startObject("georule").field("match", "foo*").startObject("mapping").field("type", "long").endObject().endObject().endObject().endArray().endObject().endObject().string();
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
BytesReference bytes = XContentFactory.jsonBuilder().startObject().startArray("foo").value(0).value(1).endArray().endObject().bytes();
ParsedDocument doc = mapper.parse("test", "type", "1", bytes);
assertEquals(4, doc.rootDoc().getFields("foo").length);
}
use of org.elasticsearch.common.bytes.BytesReference in project elasticsearch by elastic.
the class DocumentParserTests method testDynamicLongArray.
public void testDynamicLongArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
BytesReference bytes = XContentFactory.jsonBuilder().startObject().startArray("foo").value(0).value(1).endArray().endObject().bytes();
ParsedDocument doc = mapper.parse("test", "type", "1", bytes);
assertEquals(4, doc.rootDoc().getFields("foo").length);
}
use of org.elasticsearch.common.bytes.BytesReference in project elasticsearch by elastic.
the class DocumentParserTests method testDynamicFalseObject.
public void testDynamicFalseObject() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false").endObject().endObject().string();
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
BytesReference bytes = XContentFactory.jsonBuilder().startObject().startObject("foo").field("bar", "baz").endObject().endObject().bytes();
ParsedDocument doc = mapper.parse("test", "type", "1", bytes);
assertEquals(0, doc.rootDoc().getFields("foo.bar").length);
}
use of org.elasticsearch.common.bytes.BytesReference in project elasticsearch by elastic.
the class DocumentParserTests method testTypeDisabled.
public void testTypeDisabled() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").field("enabled", false).endObject().endObject().string();
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
BytesReference bytes = XContentFactory.jsonBuilder().startObject().startObject("foo").field("field", "1234").endObject().endObject().bytes();
ParsedDocument doc = mapper.parse("test", "type", "1", bytes);
assertNull(doc.rootDoc().getField("field"));
assertNotNull(doc.rootDoc().getField(UidFieldMapper.NAME));
}
Aggregations