Document mapping type name can t start with found mappingType – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.17

Briefly, this error occurs when you try to create a mapping type in Elasticsearch that starts with an underscore (‘_’). Elasticsearch reserves names starting with underscores for internal operations. To resolve this issue, rename the mapping type to something that doesn’t start with an underscore. Also, ensure that the new name adheres to Elasticsearch’s naming conventions. It’s important to note that mapping types are deprecated in Elasticsearch 7.x and removed in 8.x, so consider restructuring your data to avoid using them.

This guide will help you check for common problems that cause the log ” Document mapping type name can’t start with ‘_’; found: [” + mappingType + “] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: document, metadata, mapping, cluster.

Log Context

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

 assert mappingType != null;  if (MapperService.DEFAULT_MAPPING.equals(mappingType) == false
 && MapperService.SINGLE_MAPPING_NAME.equals(mappingType) == false
 && mappingType.charAt(0) == '_') {
 throw new InvalidTypeNameException("Document mapping type name can't start with '_'; found: [" + mappingType + "]");
 }
 Metadata.Builder builder = Metadata.builder(metadata);
 boolean updated = false;
 for (IndexMetadata indexMetadata : updateList) {
 boolean updatedMapping = false;

 

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?