一起来玩Elasticsearch,加我微信:wx1250134974
Elasticsearch认证复习准备
##概念及功能
索引 别名 就像一个快捷方式或软连接,可以指向一个或多个索引,也可以给任何一个需要索引名的API来使用。别名 带给我们极大的灵活性,允许我们做下面这些:在运行的集群中可以无缝的从一个索引切换到另一个索引、给多个索引分组 (例如, last_three_months)
、给索引的一个子集创建 视图
##使用别名
#设置别名
PUT /my_index_v1
PUT /my_index_v1/_alias/my_index
注:设置别名 my_index 指向 my_index_v1
#查看别名是my_index的索引有哪些
GET /*/_alias/my_index
#查看某个索引有哪些别名
GET /my_index_v1/_alias/*
#零停机将旧索引(my_index_v1)换成新索引(my_index_v2)
POST /_aliases
{
"actions": [
{ "remove": { "index": "my_index_v1", "alias": "my_index" }},
{ "add": { "index": "my_index_v2", "alias": "my_index" }}
]
}
#多个索引相同别名
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "test1", "alias" : "alias1" } },
{ "add" : { "index" : "test2", "alias" : "alias1" } }
]
}
POST /_aliases
{
"actions" : [
{ "add" : { "indices" : ["test1", "test2"], "alias" : "alias1" } }
]
}
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "test*", "alias" : "all_test_indices" } }
]
}
##相当于视图功能,带有过滤器属性的别名
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "test1",
"alias" : "alias2",
"filter" : { "term" : { "user" : "kimchy" } }
}
}
]
}
##带有路由属性的别名
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "test",
"alias" : "alias1",
"routing" : "1"
}
}
]
}
##搜索和索引路由分别设置
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "test",
"alias" : "alias2",
"search_routing" : "1,2",
"index_routing" : "2"
}
}
]
}
一起来玩Elasticsearch,加我微信:wx1250134974