Improved error message when the mapping document is malformed

This commit is contained in:
Manuel Bernhardt 2013-08-06 12:33:41 +02:00 committed by Simon Willnauer
parent 7f0115ba9a
commit 27518b5e41
1 changed files with 4 additions and 0 deletions

View File

@ -242,6 +242,10 @@ public class DocumentMapperParser extends AbstractIndexComponent {
throw new MapperParsingException("failed to parse mapping definition", e);
}
if (root.keySet().size() == 0) {
throw new MapperParsingException("malformed mapping definition: no JSON root object found");
}
// we always assume the first and single key is the mapping type root
if (root.keySet().size() != 1) {
throw new MapperParsingException("mapping must have the `type` as the root object");