2-Elasticsearch基础入门-索引别名

一起来玩Elasticsearch,加我微信:wx1250134974

Elasticsearch认证复习准备

https://www.elastic.co/guide/cn/elasticsearch/guide/current/getting-started.html

 

##概念及功能

索引 别名 就像一个快捷方式或软连接,可以指向一个或多个索引,也可以给任何一个需要索引名的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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值