删除所有具有相似名称的索引

a.m*_*ssa 10 elasticsearch

大家好,我的 Elasticsearch 有 100 个索引,我想通过一个查询删除它们。它们都以 myindex 开头:

myindex-1
myindex-2
myindex-3
myindex-4
  .
  .
  .
myindex-100
Run Code Online (Sandbox Code Playgroud)

当我尝试这个查询时,它不起作用:

curl -XDELETE http://localhost:9200/myindex*
Run Code Online (Sandbox Code Playgroud)

我得到:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Wildcard expressions or all indices are not allowed"}],"type":"illegal_argument_exception","reason":"Wildcard expressions or all indices are not allowed"},"status":400}
Run Code Online (Sandbox Code Playgroud)

你有什么主意吗?

Ors*_*ius 16

您可以在 kibana 开发工具中使用以下内容:

PUT /_cluster/settings
{
  "transient": {
  "action.destructive_requires_name":false

  }
}
Run Code Online (Sandbox Code Playgroud)


whi*_*s11 10

Elasticsearch文档说:

\n
\n

删除索引 API 还可以通过使用逗号分隔列表应用于多个索引,或者通过使用 \xc2\xa0_all\xc2\xa0 或 \xc2\xa0* 作为索引来应用于所有索引(小心!)。

\n

为了禁止通过通配符或\xc2\xa0_all删除索引,请将配置中的\xc2\xa0action.delta_requires_name设置设置为\xc2\xa0true。还可以通过集群更新设置 api 更改此设置。

\n
\n

因此,如果您有预定义数量的要删除的索引,这可能会起作用:

\n
curl -XDELETE http://localhost:9200/myindex-1,myindex-2,myindex-3,myindex-4\n
Run Code Online (Sandbox Code Playgroud)\n

如果您想使用通配符,则必须如上所述更新配置

\n