Mapping type name type is too long limit is length 255 but was – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when the mapping type name in Elasticsearch exceeds the maximum allowed length of 255 characters. Elasticsearch uses mapping to define how a document is indexed and how its fields are stored and indexed. To resolve this issue, you can shorten the mapping type name to be less than or equal to 255 characters. Alternatively, you can refactor your data model to reduce the complexity of your mapping types, which might result in shorter type names.

This guide will help you check for common problems that cause the log ” mapping type name [” + type + “] is too long; limit is length 255 but was [ ” 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 + “] is too long; limit is length 255 but was [” class name is MapperService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 static void validateTypeName(String type) {
 if (type.length() == 0) {
 throw new InvalidTypeNameException("mapping type name is empty");
 }
 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 + "]");

 

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?