Elasticsearch Alias
1.操作别名的两个方法:
_alias
:单个操作
_aliases
:多个操作,原子性的操作
2.创建别名
1 | curl -XPUT 'localhost:9200/dm_v1/_alias/dm' |
3.删除别名
1 | curl -XPOST 'http://localhost:9200/_aliases' -d ' |
4.删除别名的同时添加别名到新的索引,该操作时原子性的,不用担心存在别名没有指向任何索引的瞬间
Renaming an alias is a simple remove then add operation within the same API. This operation is atomic, no need to worry about a short period of time where the alias does not point to an index:
1 | curl -XPOST 'http://localhost:9200/_aliases' -d ' |
5.查询别名
通过别名查询所指向的索引:
1 | curl -XGET 'localhost:9200/_alias/dm' |
查询指向该索引下的所有别名:
1 | curl -XGET 'localhost:9200/dm_v2/_alias/*' |
6.也可以通过head检测别名是否存在
1 | curl -XHEAD -i 'localhost:9200/_alias/dm' |