![](/img/trans.png)
[英]Are index aliases and wildcard index endpoints in Elasticsearch exactly the same thing?
[英]use wildcard in ElasticSearch index template aliases
這是我的索引模板(簡體):
{
"template": "user-*",
"mappings" : {
"ESHOP_USER" : {
"properties" : {
"id" : {
"type" : "long"
},
"nickname" : {
"type" : "text"
},
"createTime" : {
"type" : "keyword"
},
"updateTime" : {
"type" : "keyword"
}
}
}
},
"aliases" : {
"user-test-alias" : {
"index" : "user-test*"
},
"user-prod-alias" : {
"index" : "user-prod*"
}
}
}
我想做的事:
名稱模式為user-*
索引共享同一模板,我想將user-test-alias
添加到名稱模式為user-test*
所有索引中,並將user-prod-alias
到名稱模式為user-prod*
所有索引中。
我得到了:
使用上面的模板,我得到了名稱模式為user-*
所有索引,並獲得了兩個別名: user-test-alias
和user-prod-alias
。
我知道如果將這個模板拆分成測試模板和生產模板,或者在創建索引后使用POST /_aliases
,我就能解決問題。 但是,只有一個索引模板有什么方法可以實現我的目標嗎?
我要做的是使用3個模板:
首先應用第一個模板(常見):
{
"template": "user-*",
"order": 0,
"mappings" : {
"ESHOP_USER" : {
"properties" : {
"id" : {
"type" : "long"
},
"nickname" : {
"type" : "text"
},
"createTime" : {
"type" : "keyword"
},
"updateTime" : {
"type" : "keyword"
}
}
}
}
}
接下來應用第二個模板(測試別名):
{
"template": "user-test-*",
"order": 1,
"aliases" : {
"user-test-alias" : {
"index" : "user-test*"
}
}
}
接下來應用第三個模板(產品別名):
{
"template": "user-prod-*",
"order": 1,
"aliases" : {
"user-prod-alias" : {
"index" : "user-prod*"
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.