Having trouble with dynamic template, not working

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`

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