es之索引的别名操作

1:增加别名

为索引school添加一个别名alias1:

1.1:创建索引

PUT student
{
"settings": {"number_of_shards": 3 , "number_of_replicas": 1}
}

PUT school
{
"settings": {"number_of_shards": 3 , "number_of_replicas": 1}
}

1.2:添加别名

POST _aliases
{
"actions" : [{"add" : {"index" : "school" , "alias" : "in1"}}]
}

POST _aliases
{
"actions" : [{"add" : {"index" : "student" , "alias" : "in1"}}]
}

2:查询别名

查询某个index下的别名:

GET school/_alias/*

 

3:删除别名

POST /_aliases
{
  "actions": [
      {"remove": {"index": "school", "alias": "in1"}}
  ]
}

4:修改别名

es没有修改别名的操作,只能先删除后添加

POST _aliases
{
"actions" : [{"remove" : {"index" : "student" , "alias" : "in1"}}],
"actions" : [{"add" : {"index" : "student" , "alias" : "in2"}}]
}

 

转载于:https://www.cnblogs.com/niutao/p/10908981.html

你可能感兴趣的:(es之索引的别名操作)