use of org.elasticsearch.common.compress.CompressedXContent in project elasticsearch by elastic.
the class CompletionFieldMapperTests method testParsingMultiValued.
public void testParsingMultiValued() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("completion").field("type", "completion").endObject().endObject().endObject().endObject().string();
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
FieldMapper fieldMapper = defaultMapper.mappers().getMapper("completion");
MappedFieldType completionFieldType = fieldMapper.fieldType();
ParsedDocument parsedDocument = defaultMapper.parse("test", "type1", "1", XContentFactory.jsonBuilder().startObject().array("completion", "suggestion1", "suggestion2").endObject().bytes());
IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name());
assertSuggestFields(fields, 2);
}
use of org.elasticsearch.common.compress.CompressedXContent in project elasticsearch by elastic.
the class DocumentParserTests method testNoLevel.
public void testNoLevel() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder().startObject().field("test1", "value1").field("test2", "value2").startObject("inner").field("inner_field", "inner_value").endObject().endObject().bytes());
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
}
use of org.elasticsearch.common.compress.CompressedXContent 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.compress.CompressedXContent 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.compress.CompressedXContent 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);
}
Aggregations