Export index template

Hi Community

i like to export a changed index template from the "Index Management". The index is a clone of an existing Index and then edited. I now need to have an export of this edited index to replicate/import it on other servers.
Is there a way how i can export such a index?

Thnks for any help here

Roberto

You can do a GET indexname/_mapping and copy the response. Then perform put indexname/_mapping on other server by using/modifying same mapping response.

It is the easiest way to do it. Let me know if this helps.

Hi Ashish

thanks for the answer. Unfortunately, this does not work. I did as you mentioned

get [MY_INDEX_NAME]/_mapping

But I get an error 404 and the result says

{
  "error": {
    "root_cause": [
      {
        "type": "index_not_found_exception",
        "reason": "no such index [MY_INDEX_NAME]",
        "resource.type": "index_or_alias",
        "resource.id": "MY_INDEX_NAME",
        "index_uuid": "_na_",
        "index": "MY_INDEX_NAME"
      }
    ],
    "type": "index_not_found_exception",
    "reason": "no such index [MY_INDEX_NAME]",
    "resource.type": "index_or_alias",
    "resource.id": "MY_INDEX_NAME",
    "index_uuid": "_na_",
    "index": "MY_INDEX_NAME"
  },
  "status": 404
}

Did I understand your command right or do I need to get the info from

get _index_template/MY_INDEX_NAME

Is there also a possibility to have that in a file and import it with an installation?

thanks

You need to replace indexname with your actual index name which is being used in your current cluster. Here is the full example -

Suppose on current cluster you have index my-index-1.

PUT /my-index-1
{
  "mappings": {
    "properties": {
      "age":    { "type": "integer" },  
      "email":  { "type": "keyword"  }, 
      "name":   { "type": "text"  }     
    }
  }
}

Just GET the mapping of index

GET my-index-1/_mapping

On another cluster hit below mapping query again to create index my-index-2 with same mapping

PUT /my-index-2
{
  "mappings": {
    "properties": {
      "age": {
        "type": "integer"
      },
      "email": {
        "type": "keyword"
      },
      "name": {
        "type": "text"
      }
    }
  }
}

As you described it works. But the index template was created/cloned under the Kibana GUI

image

We are NOT talking about a "normal" index. We are talking about an INDEX TEMPLATE.
I guess I was a little bit unprecise :frowning:

Kibana GUI uses the same API that you would use in dev tools.

In the GUI get the name of the template you want and use the API in dev tools.

GET _index_template/template-name

If it does not work, it may be a legacy template, so you need to use another endpoint

GET _template/template-name
1 Like

Hi Leandro

Thats what i expected and what i have found on the documentation. :slight_smile:
Thanks.
Maybe you can help me also how i can import that. That i did not found on the docu.

1 Like

This is also in the documentation, check it here.

1 Like