From 27518b5e4117a7dfc646e964f35a87431c4ed55f Mon Sep 17 00:00:00 2001 From: Manuel Bernhardt Date: Tue, 6 Aug 2013 12:33:41 +0200 Subject: [PATCH] Improved error message when the mapping document is malformed --- .../org/elasticsearch/index/mapper/DocumentMapperParser.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java b/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java index b51f1a555aa..a2b5759deab 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java @@ -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");