Mapping update rejected by primary – How to solve related issues

Opster Team

Feb-21, Version: 1.7-8.0

In addition to reading this guide, we recommend you run the Elasticsearch Template Optimizer to fix problems in your data modeling.

It will analyze your templates to detect issues and improve search performance, reduce indexing bottlenecks and optimize storage utilization. The Template Optimizer is free and requires no installation.

This guide will help you check for common problems that cause the log to appear. It’s important to understand the issues related to the log, so to get started, read the general overview on common issues and tips related to the Elasticsearch concepts below. Advanced users might want to skip right to the common problems section in each concept or run the template optimizer.


A mapping type used to be a separate collection inside the same index. _doc is also a mapping type. For example, before ES version 6, a forum index can have two types: user and messages. Both these types can belong to the same index, and you can search for these multiple types in a single index itself. 

But since mapping types were deprecated in ES version 6, users can only use one mapping type. You can either keep the mapping type as user or messages. Later on, for ES version 7, _doc is a part of the path.

For more information on the deprecating of mapping types, refer to this explanation

How to reproduce this log in Elasticsearch version 7.x

Create index:

PUT /my-index
 "mappings": {
   "properties": {
     "title": {
       "type": "text"

Index data:

POST /my-index/_doctype/1?pretty
 "title":"hello world"

The response will be:

 "error": {
   "root_cause": [
       "type": "invalid_type_name_exception",
       "reason": "mapping type name [_doctype] can't start with '_' unless it is called [_doc]"
   "type": "invalid_type_name_exception",
   "reason": "mapping type name [_doctype] can't start with '_' unless it is called [_doc]"
 "status": 400

The log generated is:

[INFO ][o.e.a.b.TransportShardBulkAction] [my-index][0] mapping update rejected by primary
org.elasticsearch.indices.InvalidTypeNameException: mapping type name [_doctype] can't start with '_' unless it is called [_doc]

What this error means

This log message is an INFO message saying that you cannot use any other mapping type. Elasticsearch indices now support only the single document type, _doc.

You can index a new JSON document or update a document with the _doc mapping type ONLY.

Quick troubleshooting steps

Considering the above example, you need to use _doc instead of _doctype, as shown below:

POST /my-index/_doc/1?pretty
 "title":"hello world"

Log Context

Log “{} mapping update rejected by primary” classname is
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

             try {
                    new CompressedXContent(result.getRequiredMappingUpdate(); XContentType.JSON; ToXContent.EMPTY_PARAMS);
            } catch (Exception e) {
       -> new ParameterizedMessage("{} mapping update rejected by primary"; primary.shardId()); e);
                onComplete(exceptionToResult(e; primary; isDelete; version); context; updateResult);
                return true;

            mappingUpdater.updateMappings(result.getRequiredMappingUpdate(); primary.shardId();


Watch product tour

Try AutoOps to find & fix Elasticsearch problems

Analyze Your Cluster
Skip to content