# Mapping problem with dynamic\_date\_formats (ES 2.0)

**URL:** <https://discuss.elastic.co/t/mapping-problem-with-dynamic-date-formats-es-2-0/35955>\
**Category:** Elasticsearch\
**Created:** [November 30, 2015, 9:29pm UTC](https://discuss.elastic.co/t/mapping-problem-with-dynamic-date-formats-es-2-0/35955 "2015-11-30T21:29:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![larmader](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@larmader](https://discuss.elastic.co/u/larmader)\
**Post date:** [November 30, 2015, 9:29pm UTC](https://discuss.elastic.co/t/mapping-problem-with-dynamic-date-formats-es-2-0/35955/1 "2015-11-30T21:29:29Z")

</div>

ElasticSearch 2.0:

I am using "dynamic\_date\_formats" with the _default_ type to apply date detection across all types. I have a date field with the same name that exists in multiple types.

When the first document (of a given type) with my date field is encountered, it correctly detects the date, creates the mapping for this type, and formats the date field correctly. However, when another document of a different type (that has the same date field name) is indexed, it complains that:

Mapper for [myDate] conflicts with existing mapping in other types:  
[mapper [myDate] is used by multiple types. Set update\_all\_types to true to update [format] across all types.]

Since the mapping is the same, as defined by the "dynamic\_date\_formats" configuration, why does this not work?

Here is a stripped down sequence of curl commands that repro's my problem (note that the documents are type1 and type2):

```
$ curl -XPUT http://localhost:9200/myIndex -d '{"mappings": {"_default_": 
    { "dynamic_date_formats": ["yyyy-MM-dd"]}
}}'

$ curl -XPOST http://localhost:9200/myIndex/type1 -d '{"myDate":"2015-01-01"}'

$ curl -XPOST http://localhost:9200/myIndex/type2 -d '{"myDate":"2015-01-02"}'

```

{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"Mapper for [myDate] conflicts with existing mapping in other types:\n[mapper [myDate] is used by multiple types. Set update\_all\_types to true to update [format] across all types.]"}],"type":"illegal\_argument\_exception","reason":"Mapper for [myDate] conflicts with existing mapping in other types:\n[mapper [myDate] is used by multiple types. Set update\_all\_types to true to update [format] across all types.]"},"status":400}

Any ideas?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [December 1, 2015, 9:04am UTC](https://discuss.elastic.co/t/mapping-problem-with-dynamic-date-formats-es-2-0/35955/2 "2015-12-01T09:04:52Z")

</div>

@larmader This seems to be a bug. I have raised an issue for this here: [https://github.com/elastic/elasticsearch/issues/15138](https://github.com/elastic/elasticsearch/issues/15138)

Thanks for bringing this to our attention. Until this bug is fixed there is a work around. Replace your index creation request with the following:

```auto
PUT /my_index
{
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "date_fields": {
            "match_mapping_type": "date",
            "mapping": {
              "type": "date",
              "format": "yyyy-MM-dd"
            }
          }
        }
      ]
    }
  }
}

```

Hope that helps

---

<div class="post-metadata">

**Author:** ![larmader](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@larmader](https://discuss.elastic.co/u/larmader)\
**Post date:** [December 1, 2015, 8:26pm UTC](https://discuss.elastic.co/t/mapping-problem-with-dynamic-date-formats-es-2-0/35955/3 "2015-12-01T20:26:41Z")

</div>

Awesome, this work around appears to working correctly. Thank you!

---

<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:** [July 5, 2017, 11:34pm UTC](https://discuss.elastic.co/t/mapping-problem-with-dynamic-date-formats-es-2-0/35955/4 "2017-07-05T23:34:21Z")

</div>


