# Illegal\_argument\_exception reject mapping update category in ES 7.6

**URL:** <https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761>\
**Category:** Elasticsearch\
**Created:** [May 1, 2020, 7:47pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761 "2020-05-01T19:47:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ketan\_Chachad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ketan_chachad/32/49908_2.png) [@Ketan\_Chachad](https://discuss.elastic.co/u/Ketan_Chachad)\
**Post date:** [May 1, 2020, 7:47pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761/1 "2020-05-01T19:47:58Z")

</div>

Hi,  
I have created an index in elasticsearch 7.6. The mapping is as follows:

```auto
{
  "employee_202005011710": {
    "mappings": {
      "properties": {
        "employee": {
          "properties": {
            "name": {
              "type": "text",
              "fields": {
                "raw": {
                  "type": "keyword"
                }
              },
              "analyzer": "simple"
            },
            "department": {
              "type": "text",
              "fields": {
                "raw": {
                  "type": "keyword"
                }
              },
              "analyzer": "simple"
            },
            "designation": {
              "type": "text",
              "fields": {
                "raw": {
                  "type": "keyword"
                }
              },
              "analyzer": "simple"
            }
          }
        }
      }
    }
  }
}

```

I have a python code that performs a bulk insert into this index. However I am getting the following error when the insert is performed:

```auto
{"_index":"employee_202005011710","_type":"employee","_id":"lZWw0XEBHjlZM_lHtKQq","status":400,"error":{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [employee_202005011710] as the final mapping would have more than 1 type: [_doc, employee]"}}}

```

Can someone tell me what is causing this exception?

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 1, 2020, 11:26pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761/2 "2020-05-01T23:26:40Z")

</div>

Hello @Ketan_Chachad

If the index `employee_202005011710` has been created on Elasticsearch 7.x, the default document type is `_doc`.

You're indexing a document providing `employee` as value of the `_type`.

Since [Elasticsearch 6.x it is no more possible to have multiple types within the same index](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/removal-of-types.html) and since Elasticsearch 7.x providing the document type is deprecated and it is no more required (it defaults to `_doc`).

There are 2 ways to solve this:

1. Delete the index and put the the mapping with the parameter `include_type_name` and continue indexing the documents using `employee` as document `_type`

```auto
PUT employee_202005011710?include_type_name
{
  "mappings": {
    "employee": { # this is the type name
      "properties": {
        "employee": { # this is the name of a field
      }
    }
  }
}

```

1. Just change the indexing settings on your Python code to no more provide a custom document type or force it to `_doc`.

* * *

As a side note, I notice the mapping has a `employee` property at the root, which means all fields will be within the key `employee`.

---

<div class="post-metadata">

**Author:** ![Ketan\_Chachad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ketan_chachad/32/49908_2.png) [@Ketan\_Chachad](https://discuss.elastic.co/u/Ketan_Chachad)\
**Post date:** [May 4, 2020, 1:43pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761/3 "2020-05-04T13:43:12Z")

</div>

Thanks a lot @Luca_Belluccini for your solutions!  
I tried both solutions and they worked.  
However when I created a new index with include\_type\_name=true, I got the following message:  
`#! Deprecation: [types removal] Using include_type_name in create index requests is deprecated. The parameter will be removed in the next major version.`  
Does this mean that going forward solution #2 (using \_doc or no type) is the future ready solution?

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 4, 2020, 3:44pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761/4 "2020-05-04T15:44:18Z")

</div>

Exactly, not providing the `_doc` is the future proof solution.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2020, 3:44pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reject-mapping-update-category-in-es-7-6/230761/5 "2020-06-01T15:44:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
