按别名删除索引

问题描述 投票:0回答:2

使用Elasticsearch,我可以通过名称删除索引:

DELETE my_index
{}

但我无法通过别名删除它:

DELETE my_index_alias
{}

错误是:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "The provided expression [my_index_alias] matches an alias, specify the corresponding concrete indices instead."
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "The provided expression [my_index_alias] matches an alias, specify the corresponding concrete indices instead."
  },
  "status": 400
}

有没有办法按别名删除索引?

elasticsearch kibana
2个回答
0
投票

我相信你想要实现的目标是不可能的。目前,ElasticSearch DELETE API支持以下内容:

  1. 您可以删除索引

curl -XDELETE 'http://localhost:9200/{indexname}'

当且仅当{indexname}是具体索引时,删除{indexname}。

或2.删除别名

curl -XDELETE 'http://localhost:9200/_alias/{aliasname}'

当且仅当{aliasname}是索引别名时,删除{aliasname}。


0
投票

您提到的错误说您使用语法DELETE whatever_you_put_here删除的内容实际上是删除索引的语法或查询,并建议用户如果要删除indexes,则无法通过删除别名来完成。

当您为例如创建别名时myalias和你将一个样本索引myindex关联到它,删除索引myindex后你的别名myalias也会被删除。

但是,当您创建别名并将两个索引关联到它时,您需要删除要删除的别名的索引。

alias中不存在空的Elasticsearch,你无法创建它。

请注意,您可以通过执行以下查询来检查您拥有的别名列表

GET /_alias

现在,如果您只想删除aliasindex,可以使用下面的DELETE查询删除它。

DELETE myindex/_alias/myalias

请注意,如果您有两个索引引用相同的别名,则别名将继续存在,直到您对两个索引执行上述DELETE操作。

有没有办法使用别名删除索引

至于上面的查询,我不认为这是可能的,也没有意义。

© www.soinside.com 2019 - 2024. All rights reserved.