添加索引別名
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions": [
{"add": {"index": "test1", "alias": "alias1"}}
]
}'
刪除索引別名
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions": [
{"remove": {"index": "test1", "alias": "alias1"}}
]
}'
重命名一個別名就是一個簡單的remove然後add的操作,也是使用相同的API。這個操作是原子的,無需擔心這個別名未能指向一個索引的簡短時間:
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions": [
{"remove": {"index": "test1", "alias": "alias1"}},
{"add": {"index":"test1", "alias": "alias2"}}
]
}'
```
delete形式刪除別名 你也可以使用複數的_aliases。例子
```javascript
curl -XDELETE 'localhost:9200/users/_alias/user_12'