Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempting to delete all the data for an Index in Elasticsearch

I am trying to delete all the documents, i.e. data from an index. I am using v6.6 along with the dev tools in Kibana.

In the past, I have done this operation successfully but now it is saying 'not found'

{
  "_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
}

Here is my kibana statement

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

Also, the index GET operation which verified the index has data and exists:

GET new-index/doc/_search

I verified the type is doc but I can post the whole mapping, if needed.

like image 935
cluis92 Avatar asked Sep 07 '25 05:09

cluis92


1 Answers

I was able to resolve the issue by using a delete by query:

POST new-index/_delete_by_query
{
  "query": {
    "match_all": {}
  }
}
like image 195
cluis92 Avatar answered Sep 09 '25 04:09

cluis92