# Dynamic mapping strict and date data type (ES 6.4)

**URL:** <https://discuss.elastic.co/t/dynamic-mapping-strict-and-date-data-type-es-6-4/170667>\
**Category:** Elasticsearch\
**Created:** [March 4, 2019, 4:05am UTC](https://discuss.elastic.co/t/dynamic-mapping-strict-and-date-data-type-es-6-4/170667 "2019-03-04T04:05:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishant.saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishant.saini/32/41489_2.png) [@nishant.saini](https://discuss.elastic.co/u/nishant.saini)\
**Post date:** [March 4, 2019, 4:05am UTC](https://discuss.elastic.co/t/dynamic-mapping-strict-and-date-data-type-es-6-4/170667/1 "2019-03-04T04:05:12Z")

</div>

I have created an index with following mapping:

```
{
  "mappings": {
    "_doc": {
      "dynamic": "strict",
      "properties": {
        "created ": {
          "type": "date",
          "format": "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
        }
      }
    }
  }
}

```

Then I try index a new document as:

```
PUT test1/_doc/1
{
  "created": "2016/01/01"
}

```

This is resulting in the following error:

```
{
  "error": {
    "root_cause": [
      {
        "type": "strict_dynamic_mapping_exception",
        "reason": "mapping set to strict, dynamic introduction of [created] within [_doc] is not allowed"
      }
    ],
    "type": "strict_dynamic_mapping_exception",
    "reason": "mapping set to strict, dynamic introduction of [created] within [_doc] is not allowed"
  },
  "status": 400
}

```

When I change `"dynamic": "strict"` to `"dynamic": false` then even though the document get indexed but the field doesn't behave like a date field. The range query doesn't work. If I completely remove the dynamic param from mapping then everything works as expected but the requirement is to keep dynamic as strict.

Please explain me why such a behaviour and how it can be solved.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [March 4, 2019, 9:08am UTC](https://discuss.elastic.co/t/dynamic-mapping-strict-and-date-data-type-es-6-4/170667/2 "2019-03-04T09:08:17Z")

</div>

> [@nishant.saini](#):
>
> `"created ": {`

The field name in your mapping has a trailing space.

---

<div class="post-metadata">

**Author:** ![nishant.saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishant.saini/32/41489_2.png) [@nishant.saini](https://discuss.elastic.co/u/nishant.saini)\
**Post date:** [March 4, 2019, 9:24am UTC](https://discuss.elastic.co/t/dynamic-mapping-strict-and-date-data-type-es-6-4/170667/3 "2019-03-04T09:24:10Z")

</div>

Thanks a lot. Sometimes it just a silly mistake.

---

<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:** [April 1, 2019, 9:24am UTC](https://discuss.elastic.co/t/dynamic-mapping-strict-and-date-data-type-es-6-4/170667/4 "2019-04-01T09:24:17Z")

</div>

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