尝试在Elasticsearch中删除索引的所有数据

时间:2019-10-17 14:20:31

标签: elasticsearch kibana

我正在尝试删除所有文档,即索引中的数据。我在Kibana中使用v6.6和开发工具。

过去,我已经成功完成了此操作,但现在却说“未找到”

{
  "_index" : "new-index",
  "_type" : "doc",
  "_id" : "_query",
  "_version" : 1,
  "result" : "not_found",
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "_seq_no" : 313,
  "_primary_term" : 7
}

这是我的基巴纳语声明

DELETE /new-index/doc/_query
   {
      "query": {
        "match_all": {}
      }
    }

此外,验证索引的索引GET操作具有数据并存在:

GET new-index/doc/_search

我已验证类型为doc,但可以根据需要发布整个映射。

5 个答案:

答案 0 :(得分:0)

我可以通过使用按查询删除功能来解决此问题:

POST new-index/_delete_by_query
{
  "query": {
    "match_all": {}
  }
}

答案 1 :(得分:0)

Delete documents is a problematic way to clear data

首选删除索引:

DELETE [your-index]

从kibana控制台中。

然后从头开始重新创建。

更可取的方法是为索引创建一个template,该索引也会与第一个索引文档一起创建索引。

答案 2 :(得分:0)

更简单的方法是在Kibana中导航到Management-> Elasticsearch index mapping,然后通过复选框选择要删除的索引,然后单击Manage index-> {{ 1}}或delete index,具体取决于您的需求。

enter image description here

答案 3 :(得分:0)

当前唯一的解决方案是要么删除索引本身(更快),要么删除查询(更快)

https://www.elastic.co/guide/en/elasticsearch/reference/7.4/docs-delete-by-query.html

POST new-index/_delete_by_query?conflicts=proceed
{
  "query": {
    "match_all": {}
  }
}

删除API仅删除单个文档https://www.elastic.co/guide/en/elasticsearch/reference/7.4/docs-delete.html

答案 4 :(得分:0)

我的猜测是有人更改了字段的名称,现在该字段的DB(NoSQL)和Elasticsearch字符串名称不匹配。因此,Elasticsearch尝试删除该字段,但该字段“未找到”。

这不是我会睡不着的错误。