首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elasticsearch ILM - ELK

Elasticsearch ILM - ELK
EN

Stack Overflow用户
提问于 2022-05-11 23:34:16
回答 1查看 162关注 0票数 0

我试图用两种模式创建索引模板,我的问题是

  • 我可以在模板中添加两个模式吗?
  • 还是唯一的方法是为每个模式创建一个索引模板?

我的政策

代码语言:javascript
复制
PUT _ilm/policy/my_first_policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_primary_shard_size": "1b",
            "max_docs": 2
          }
        }
      },
      "delete": {
        "min_age": "1m",
        "actions": {
          "delete": {} 
        }
      }
    }
  }
}

具有两种模式的索引模板

代码语言:javascript
复制
PUT _index_template/my_first_template
{
  "index_patterns": ["test-one-*", "test-two-*"], 
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1,
      "index.lifecycle.name": "my_first_policy", 
      "index.lifecycle.rollover_alias": "my-test-alias" 
    }
  }
}

启动索引

代码语言:javascript
复制
PUT test-one-000001
{
  "aliases": {
    "test-one":{
      "is_write_index": true 
    }
  }
}
 
PUT test-two-000001
{
  "aliases": {
    "test-two":{
      "is_write_index": true 
    }
  }
}

我得到以下错误

代码语言:javascript
复制
illegal_argument_exception: index.lifecycle.rollover_alias [my-test-alias] does not point to index [test-one-000001]

它似乎使用的是模板中的一个模式,当我使用模板和第一个文档中定义的相同别名时,这就是我的意思。

代码语言:javascript
复制
PUT _index_template/my_first_template
{
  "index_patterns": ["test-one-*"], 
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1,
      "index.lifecycle.name": "my_first_policy", 
      "index.lifecycle.rollover_alias": "my-test-alias" 
    }
  }
}

PUT test-one-000001
{
  "aliases": {
    "my-test-alias":{
      "is_write_index": true 
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-12 05:58:34

这里的问题是index.lifecycle.rollover_alias只能附加到单个索引,它是该策略的写索引

ie -不能将两个索引附加在别名上,这两个索引都是写索引。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72208633

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档