elasticsearch:从现有索引创建索引模板

时间:2021-02-02 12:06:25

标签: templates elasticsearch indexing

我在 Elasticsearch 中创建了一个索引。现在我需要为这个索引创建一个索引模板。我没有在文档中找到与此主题相关的任何内容。我的问题是:是否可以根据 Elasticsearch 中的现有索引创建索引模板? tnks

1 个答案:

答案 0 :(得分:0)

是的,您需要分两步完成:

首先,使用

检索索引映射和设置
GET my-index

然后,您可以使用从第一步得到的结果,通过运行来创建 index template

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
}