diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/src/main/java/org/elasticsearch/index/mapper/MapperService.java index be9b54a3ab25e..6bfac74e648de 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -191,6 +191,9 @@ public void add(String type, String mappingSource) { // instances of field mappers to properly remove existing doc mapper private void add(DocumentMapper mapper) { synchronized (mutex) { + if (mapper.type().length() == 0) { + throw new InvalidTypeNameException("mapping type name is empty"); + } if (mapper.type().charAt(0) == '_') { throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] can't start with '_'"); }