# Adding a field to the default mapping

**URL:** <https://discuss.elastic.co/t/adding-a-field-to-the-default-mapping/104754>\
**Category:** Elasticsearch\
**Created:** [October 20, 2017, 10:21pm UTC](https://discuss.elastic.co/t/adding-a-field-to-the-default-mapping/104754 "2017-10-20T22:21:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkaeding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaeding/32/12454_2.png) [@pkaeding](https://discuss.elastic.co/u/pkaeding)\
**Post date:** [October 20, 2017, 10:21pm UTC](https://discuss.elastic.co/t/adding-a-field-to-the-default-mapping/104754/1 "2017-10-20T22:21:28Z")

</div>

I am having trouble adding a field (named `user.privateAttributes`) to an existing `_default_` mapping. Instead of adding the new field, it is replacing the entire mapping with a new single-field mapping.

When I run the same call on a regular mapping (for a type, not `_default_`), the field is added as I expect, with other fields remaining untouched.

I'm running ES 2.4.1.

My request to add the field is like this:

```auto
curl -s -XPUT http://localhost:9200/users/_mapping/_default_ -d'
  {
      "properties": {
          "user": {
              "properties": {
                  "privateAttributes": {
                      "type": "string",
                      "fields": {
                          "untouched": {
                              "type": "string",
                              "index": "not_analyzed"
                          }
                      }
                  }
              }
          }
      }
  }'

```

How can I modify the default mapping to add a new field, leaving the existing fields unchanged?

---

<div class="post-metadata">

**Author:** ![pkaeding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaeding/32/12454_2.png) [@pkaeding](https://discuss.elastic.co/u/pkaeding)\
**Post date:** [October 20, 2017, 11:29pm UTC](https://discuss.elastic.co/t/adding-a-field-to-the-default-mapping/104754/2 "2017-10-20T23:29:58Z")

</div>

Ahh, I see that in [later versions of the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/default-mapping.html), this note is added:

> When updating the _default_ mapping with the PUT mapping API, the new mapping is not merged with the existing mapping. Instead, the new _default_ mapping replaces the existing one.

I guess this limitation was in 2.4 as well, but just not called out in the docs.

---

<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:** [November 17, 2017, 11:30pm UTC](https://discuss.elastic.co/t/adding-a-field-to-the-default-mapping/104754/3 "2017-11-17T23:30:04Z")

</div>

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