# Having trouble with dynamic template, not working

**URL:** <https://discuss.elastic.co/t/having-trouble-with-dynamic-template-not-working/163414>\
**Category:** Elasticsearch\
**Created:** [January 8, 2019, 5:34pm UTC](https://discuss.elastic.co/t/having-trouble-with-dynamic-template-not-working/163414 "2019-01-08T17:34:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drsaison](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@drsaison](https://discuss.elastic.co/u/drsaison)\
**Post date:** [January 8, 2019, 5:34pm UTC](https://discuss.elastic.co/t/having-trouble-with-dynamic-template-not-working/163414/1 "2019-01-08T17:34:01Z")

</div>

```
I created schema with the following dynamic_template
{
    "mappings": {
        "site": {
            "properties": {
                "id": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "location": {
                    "type": "geo_point"
                },
                "name": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "organization": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                }
            },
            "dynamic_templates": [
            {
                "longs_as_strings": {
                	"match_mapping_type": "string",
                    "match": "*_number",
                    "mapping": {
                        "type": "long"
                    }
                }
            },
			{
                "dates_as_strings": {
                	"match_mapping_type": "string",
                    "match": "*_datetime",
                    "mapping": {
                        "type": "date",
                       "format": "YYYYMMddHHmmss"
                    }
                }
            }            
            ]
        }
    }
}

but when I created a site with the following payload from postman
{
        "id": "2",
        "name": "ncr",
        "organization": "ncr",
        "location": {
            "lat": 33.779,
            "lon": -84.389
        },
        "createdDate": 1546967922910,
        "updatedDate_datetime": "20180101121212",
        "test_number": "123"
    }
 I would expect updatedDate_timestamp field will be saved as a date as createdDate, and test_number saved as a number but both fields remain as string values from a get call
{
    "_index": "sites",
    "_type": "site",
    "_id": "2",
    "_version": 1,
    "found": true,
    "_source": {
        "id": "2",
        "name": "ncr",
        "organization": "ncr",
        "location": {
            "lat": 33.779,
            "lon": -84.389
        },
        "createdDate": 1546967922910,
        "updatedDate_datetime": "20180101121212",
        "test_number": "123"
    }
}
any idea what I did wrong? Thank you for your help. I am using ElasticSearch 6.5.1`Preformatted text`
```

---

<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:** [February 5, 2019, 5:34pm UTC](https://discuss.elastic.co/t/having-trouble-with-dynamic-template-not-working/163414/2 "2019-02-05T17:34:03Z")

</div>

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