前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Elasticsearch alias别名管理小结

Elasticsearch alias别名管理小结

作者头像
授客
发布2019-09-11 16:40:58
6760
发布2019-09-11 16:40:58
举报
文章被收录于专栏:授客的专栏授客的专栏

建创测试数据 1

创建别名 2

移除别名 3

创建测试数据 4

批量操作 5

例1. 5

例2. 把多个索引添加到一个别名中 6

例3. 使用通配符 8

测试环境:

Win elasticsearch-5.4.1

1. 别名管理

建创测试数据

PUT test1_index

POST test1_index/doctype/1

{

"name":"shouke",

"addr":"深圳"

}

POST test1_index/doctype/2

{

"name":"shou ke",

"addr":"深圳"

}

POST test1_index/doctype/_search

创建别名

POST /_aliases

{

"actions": [

{

"add": {

"index": "test1_index",

"alias": "test1_index_alias"

}

}

]

}

说明:index 为要创建别名的“源索引”, alias 别名

搜索验证

POST /test1_index_alias/_search

Elasticsearch <wbr>alias别名管理小结
Elasticsearch <wbr>alias别名管理小结

移除别名

POST /_aliases

{

"actions": [

{

"remove": {

"index": "test1_index",

"alias": "test1_index_alias"

}

}

]

}

验证

POST /test1_index_alias/_search

Elasticsearch <wbr>alias别名管理小结
Elasticsearch <wbr>alias别名管理小结

创建测试数据

PUT /test2_index

POST test2_index/doctype/1

{

"name":"shouke",

"addr":"福建"

}

POST test2_index/doctype/2

{

"name":"shou ke",

"addr":"福建"

}

POST /_aliases

{

"actions": [

{

"add": {

"index": "test1_index",

"alias": "test_index_alias"

}

}

]

}

批量操作

例1.

POST /_aliases

{

"actions": [

{

"remove": {

"index": "test1_index",

"alias": "test_index_alias"

}

},

{

"add": {

"index": "test2_index",

"alias": "test_index_alias"

}

}

]

}

POST /test_index_alias/_search

Elasticsearch <wbr>alias别名管理小结
Elasticsearch <wbr>alias别名管理小结

例2. 把多个索引添加到一个别名中

重置环境

POST /_aliases

{

"actions": [

{

"remove": {

"index": "test1_index",

"alias": "test_index_alias"

}

},

{

"remove": {

"index": "test2_index",

"alias": "test_index_alias"

}

}

]

}

添加别名

POST /_aliases

{

"actions": [

{

"add": {

"index": "test1_index",

"alias": "test_index_alias"

}

},

{

"add": {

"index": "test2_index",

"alias": "test_index_alias"

}

}

]

}

验证

Elasticsearch <wbr>alias别名管理小结
Elasticsearch <wbr>alias别名管理小结

等效做法

POST /_aliases

{

"actions": [

{

"add": {

"indices": [

"test1_index",

"test2_index"

],

"alias": "test_index_alias"

}

}

]

}

例3. 使用通配符

把所有test开头的索引都添加到别名all_test_indices中

POST /_aliases

{

"actions": [

{

"add": {

"index": "test*",

"alias": "all_test_indices"

}

}

]

}

更多资料参考:

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html#alias-management

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-01-31 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档