Mapping type name type can t start with unless it is called – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when you try to create a mapping type in Elasticsearch that starts with an underscore (‘_’), which is not allowed unless it is specifically called ‘_doc’. Elasticsearch reserves names starting with underscores for internal operations. To resolve this issue, you can either rename your mapping type to not start with an underscore or, if you’re using a version of Elasticsearch that supports it, use ‘_doc’ as your mapping type.

This guide will help you check for common problems that cause the log ” mapping type name [” + type + “] can’t start with ‘_’ unless it is called [ ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: mapping, index.

Log Context

Log “mapping type name [” + type + “] can’t start with ‘_’ unless it is called [” class name is MapperService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (type.length() > 255) {
 throw new InvalidTypeNameException("mapping type name [" + type + "] is too long; limit is length 255 but was ["
 + type.length() + "]");
 }
 if (type.charAt(0) == '_' && SINGLE_MAPPING_NAME.equals(type) == false) {
 throw new InvalidTypeNameException("mapping type name [" + type + "] can't start with '_' unless it is called ["
 + SINGLE_MAPPING_NAME + "]");
 }
 if (type.contains("#")) {
 throw new InvalidTypeNameException("mapping type name [" + type + "] should not include '#' in it");
 }

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?