How to update index template

Our cluster have about 170 index templates.
I need to update all templates , include the settings:

PUT _template/testovaci
{
  "settings": {
    "index.routing.allocation.include.data": "hot"
  }
}

but this syntax does not work
I have to use this type of syntax but this completely recreates the template and removes all mappings etc..

PUT _template/testovaci
{
  "index_patterns" : [
      "testovaci*"
    ],
  "settings": {
    "index.routing.allocation.include.data": "hot"
  }
}

Could you please help me to find the way how to update the mapping of all index templates?

I think you trying to put some setting so all index will go to hot storage correct?

if so you can do this.

PUT */_settings
{
  "index.routing.allocation.require.box_type": "hot"
}

ofcouse you can test it by following just one index.

PUT <inde_name>/_settings
{
  "index.routing.allocation.require.box_type": "hot"
}

you can get the result for confirmation

GET */_settings?include_defaults=true&filter_path=**.routing.**

@elasticforme
thank you I know this works on indices but it does not work on index templates.
This approach works on existing indices only, but newly created indexes follows settings in its index_templates and this I want to modify.

I tried to create default template on index pattern [*] with low prio but the templates with higher priority replaces it . So it seems I will have to download all index_templates update the settings and upload them back.

then you have to create a template and attach

now all new index_pattern will have this template

PUT _template/hot_storage
{
"index_patterns": "*",
"settings" : {
"index.routing.allocation.require.box_type": "hot"
}
}

1 Like

@elasticforme
yes you are right
I forgot I can use multiple templates on index.

  1. default templates matching all indices [*] and giving them hot settings
  2. specific template for each index [index_name] and provide specific settings

I forgot this works,
thank you

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