Index template files are not working

Hi,

When POSTing my template json to: http://es:9200/_template/gaia_template everything works just fine, but when I place it under ES_HOME/config/templates/gaia_template.json, nothing happens.
I've tried to look inside ES server logs in debug mode but could not find any suspicious thing.
I'm using ES 2.1.0

This is the json I'm using:

{
  "template": "gaia_*",
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "strings": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        {
          "timestamp_field": {
            "match": "timestamp",
            "mapping": {
              "type": "date"
            }
          }
        }
      ]
    }
  }
}

Any comment will be appreciated.

Thanks!
Shay

From Elasticsearch version 2.0, mappings in config files are no longer supported, so what you are seeing is expected.

1 Like

Thanks for the valuable information!
Maybe you know to tell why this ability is not supported anymore?

To me having config file is better compare to work with the API, why:

  1. Working with the API means that I need post-deployment process that will create the templates on the fly + a risk that a new index will be created without the template being applied yet.

  2. We work with docker to deploy ES, hence having pre-configure image with the config file in it is better for us.

Thanks,
Shay

The issue on Github related to this change can be found here, although most of the discussion takes place at the corresponding pull request.