英文:
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
一些建议:
- 将refresh_interval减少至最多30秒。
- 减少副本数量至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:
- Decrease the refresh_interval to at max 30s
- Decrease the replica count 1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论