parent
42a112f50b
commit
a557ee8daf
|
@ -28,6 +28,7 @@ import org.apache.lucene.queries.TermFilter;
|
|||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.ElasticsearchIllegalStateException;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||
|
@ -214,7 +215,13 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
|
|||
} else if (fieldName.equals("path")) {
|
||||
builder.pathType(parsePathType(name, fieldNode.toString()));
|
||||
} else if (fieldName.equals("properties")) {
|
||||
if (fieldNode instanceof Collection && ((Collection) fieldNode).isEmpty()) {
|
||||
// nothing to do here, empty (to support "properties: []" case)
|
||||
} else if (!(fieldNode instanceof Map)) {
|
||||
throw new ElasticsearchParseException("properties must be a map type");
|
||||
} else {
|
||||
parseProperties(builder, (Map<String, Object>) fieldNode, parserContext);
|
||||
}
|
||||
} else if (fieldName.equals("include_in_all")) {
|
||||
builder.includeInAll(nodeBooleanValue(fieldNode));
|
||||
} else {
|
||||
|
|
|
@ -56,4 +56,12 @@ public class SimpleObjectMappingTests extends ElasticsearchTestCase {
|
|||
// all is well
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyArrayProperties() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startArray("properties").endArray()
|
||||
.endObject().endObject().string();
|
||||
MapperTestUtils.newParser().parse(mapping);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue