简体   繁体   中英

elasticsearch: create index tamplate from existing index

I have created an index in Elasticsearch. Now I need to create an index template for this index. I didn't find in the documentation any related with this topic. My question is: is it possible to create an index template fram an existing index in Elasticsearch? tnks

Yes, you need to do it in two steps:

First, retrieve the index mappings and settings using

GET my-index

Then, you can use the results you got from the first steps in order to create an index template by running

PUT _index_template/my_index_template
{
  "index_patterns": ["my-index-*"],
  "template": {
     "mappings": {
       ...                <--- add the mappings you got from the first call
     },
     "settings": {
       ...                <--- add the settings you got from the first call
     },
     "aliases": {
       ...                <--- add the aliases you got from the first call
     }
  },
  "priority": 200,
  "composed_of": [],
  "version": 1
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM