# Delete documents from ES index\_5.4 based on timestamp

**URL:** <https://discuss.elastic.co/t/delete-documents-from-es-index-5-4-based-on-timestamp/145281>\
**Category:** Elasticsearch\
**Created:** [August 21, 2018, 5:21am UTC](https://discuss.elastic.co/t/delete-documents-from-es-index-5-4-based-on-timestamp/145281 "2018-08-21T05:21:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![reddyvishnu01](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@reddyvishnu01](https://discuss.elastic.co/u/reddyvishnu01)\
**Post date:** [August 21, 2018, 5:21am UTC](https://discuss.elastic.co/t/delete-documents-from-es-index-5-4-based-on-timestamp/145281/1 "2018-08-21T05:21:54Z")

</div>

Hi,

I am working on script which includes "Delete the data from OLD ES Indices" by using "timestamp" query.

TIme stamp looks like: timestamp August 21st 2018, 10:10:25.765

i tried with inputs from couple of blocks but not working , please advice?

Tried Below:  
POST healthevents-2018-08-21/\_delete\_by\_query  
{  
"query": {  
"range" : {  
"\_timestamp" : {  
"lt" : "now-30d"  
}  
}  
}  
}  
########################  
POST healthevents-2018-08-21/\_delete\_by\_query  
{  
"query": {  
"range" : {  
"@timestamp" : {  
"lt" : "datetime.datetime.utcnow()"

}  
}  
}  
}

OUT PUT:  
{  
"took": 0,  
"timed\_out": false,  
"total": 0,  
"deleted": 0,  
"batches": 0,  
"version\_conflicts": 0,  
"noops": 0,  
"retries": {  
"bulk": 0,  
"search": 0  
},  
"throttled\_millis": 0,  
"requests\_per\_second": -1,  
"throttled\_until\_millis": 0,  
"failures": []  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 18, 2018, 5:25am UTC](https://discuss.elastic.co/t/delete-documents-from-es-index-5-4-based-on-timestamp/145281/2 "2018-09-18T05:25:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
