Elastic search dynamic template not working

867 views Asked by At

I have elastic search stack: Where I have template

{
 "template": "vivek-*",
"settings": {
  "number_of_shards": 40,
  "index.mapper.dynamic": true
},
"dynamic_templates": [
  {
    "date": {
      "match": "*Utc",         
      "mapping": {
        "type": "date"
      }
    }
  }
],
"mappings": {
  "vivek": {
    "_source": {
      "enabled": true
    },
    "properties": {


    }
  }
}

} I am putting following document:

{
    "attribute1Utc": 1483999887069
}

Elastic search is still detecting it as: attribute1Utc number

1

There are 1 answers

0
Val On BEST ANSWER

You've simply got your mapping wrong, the dynamic_templates section needs to go inside the mapping type, like this. It will work afterwards.

{
  "template": "vivek-*",
  "settings": {
    "number_of_shards": 40,
    "index.mapper.dynamic": true
  },
  "mappings": {
    "vivek": {
      "_source": {
        "enabled": true
      },
      "dynamic_templates": [
        {
          "date": {
            "match": "*Utc",
            "mapping": {
              "type": "date"
            }
          }
        }
      ],
      "properties": {}
    }
  }
}