aka_code
aka_code

Reputation: 84

Is there a way to delete data uploaded today from an index in elasticsearch/kibana

I want to delete data that has been pushed today into elasticsearch index named index1. How to do so?

My index looks like this :

 {
    "_index" : "index1",
    "_type" : "_doc",
    "_id" : "zIRLIB9H5oRSfavviZ",
    "_score" : 1.0,
    "_source" : {
      "name" : "ramen",
      "class" : "5",
      "age" : "12",
    }
  },
  {
    "_index" : "index1",
    "_type" : "_doc",
    "_id" : "zYRLI3IBoRSfawviy",
    "_score" : 1.0,
    "_source" : {
      "name" : "tom",
      "class" : "6",
      "age" : "51",
   }
 }

I want to delete the second set of data which is pushed today so that my index looks like this :.

 {
    "_index" : "index1",
    "_type" : "_doc",
    "_id" : "zIRLIB9H5oRSfavviZ",
    "_score" : 1.0,
    "_source" : {
      "name" : "ramen",
      "class" : "5",
      "age" : "12",
    }
  }

Upvotes: 0

Views: 166

Answers (1)

Val
Val

Reputation: 217274

If you can delete the index altogether then just run

DELETE index1

Otherwise, if you want to keep the index but delete everything in there, run

POST index1/_delete_by_query?q=*

And if you want to keep the index because you have data from other days and only want to delete the data from today, then you can do

POST index1/_delete_by_query?q=@timestamp:[now/d TO *]

(Make sure to replace @timestamp by your data field)

Upvotes: 1

Related Questions