无法获取ElasticSearch V8.6.2中新创建模板的别名。

huangapple go评论56阅读模式
英文:

Could not get alias of newly created template in ElasticSearch V8.6.2

问题

我是ElasticSearch的新手,刚尝试使用以下命令创建模板。
PUT https://myip:myport/_template/templatetest

{
    "index_patterns": ["templatetest-*"],
    "order": 999,
    "settings": {
        "refresh_interval":"300s", 
        "number_of_shards":6, 
        "number_of_replicas":2
    },
    "mappings": {
        "properties": {
            "ActionName": {"type":"text"}
        }
    },
    "aliases": {
        "templatetest_all" : {}
    }
}

之后,我尝试使用以下命令查询别名,但失败了。
GET https://myip:myport/_alias/templatetest_all

我的问题是,是我创建请求还是查询请求有问题吗?

谢谢。

英文:

I am a rookie to the ElasticSearch, and just tried to create a template with the following command.
PUT https://myip:myport/_template/templatetest

{
    "index_patterns": ["templatetest-*"],
    "order": 999,
    "settings": {
        "refresh_interval":"300s", 
        "number_of_shards":6, 
        "number_of_replicas":2
    },
    "mappings": {
        "properties": {
            "ActionName": {"type":"text"}
        }
    },
    "aliases": {
        "templatetest_all" : {}
    }
}

After this, I tried to query the alias with below command, but failed.
GET https://myip:myport/_alias/templatetest_all

My question is that if there is anything wrong with my create request or query request.

Thanks.

答案1

得分: 0

_template(传统版本)是旧版本。我建议使用_index_template

创建一个_index_template

PUT _index_template/test_template
{
  "index_patterns": ["templatetest-*"],
  "order": 999,
  "settings": {
      "refresh_interval":"300s", 
      "number_of_shards":6, 
      "number_of_replicas":2
  },
  "mappings": {
      "properties": {
          "ActionName": {"type":"text"}
      }
  },
  "aliases": {
      "templatetest_all" : {}
  }
}

创建索引

PUT templatetest-001
PUT templatetest-002

使用别名检查您的索引

GET _cat/indices/templatetest_all?v

您还可以使用别名搜索数据

GET templatetest_all/_search

一些建议:

  1. 将refresh_interval减少至最多30秒。
  2. 减少副本数量至1。
英文:

The _template (legacy) is the old one. I recommend using _index_template.

create an _index_template

PUT _index_template/test_template
{
  "index_patterns": ["templatetest-*"],
  "order": 999,
  "settings": {
      "refresh_interval":"300s", 
      "number_of_shards":6, 
      "number_of_replicas":2
  },
  "mappings": {
      "properties": {
          "ActionName": {"type":"text"}
      }
  },
  "aliases": {
      "templatetest_all" : {}
  }
}

Create indices

PUT templatetest-001
PUT templatetest-002

Check your indices with an alias

GET _cat/indices/templatetest_all?v

You can also search your data with alias

GET templatetest_all/_search

Some recommendations:

  1. Decrease the refresh_interval to at max 30s
  2. Decrease the replica count 1

huangapple
  • 本文由 发表于 2023年3月9日 17:08:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75682453.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定