# Delete every other row?

**URL:** <https://discuss.elastic.co/t/delete-every-other-row/2621>\
**Category:** Elasticsearch\
**Created:** [June 13, 2015, 2:32pm UTC](https://discuss.elastic.co/t/delete-every-other-row/2621 "2015-06-13T14:32:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)\
**Post date:** [June 13, 2015, 2:32pm UTC](https://discuss.elastic.co/t/delete-every-other-row/2621/1 "2015-06-13T14:32:15Z")

</div>

I am thinking about pulling in my Graphite/statd data in to ElasticSearch. Over time I want to remove data to gradually make the index smaller, I was wondering if there was a way that I could write a delete statement to delete all but 1 document per minute.

For example:  
The application/statsd might send out 23 lines for the same static within 1 minute. After about a day, I only want to retain 1 record per minute and a week later I want to retain only 1 document every 10 minutes, and so on. A month or year from now I don't care about the 1 minute transactions just a summary of the hour or day so there is no reason to keep the second and minute data.

I know I could write this in a script to query the documents and delete the ones individually but I was hoping to learn of a fancy way of doing this with a ES Query instead.

Thanks for any feed back.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 14, 2015, 2:38am UTC](https://discuss.elastic.co/t/delete-every-other-row/2621/2 "2015-06-14T02:38:06Z")

</div>

Not with a query, maybe with a script though.

---

<div class="post-metadata">

**Author:** ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)\
**Post date:** [June 15, 2015, 12:47am UTC](https://discuss.elastic.co/t/delete-every-other-row/2621/3 "2015-06-15T00:47:53Z")

</div>

Yah I figured it would probably be that answer was just hoping for some black magic rather then doing it though a script. Ah well Thanks!

---

<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:** [July 6, 2017, 12:07am UTC](https://discuss.elastic.co/t/delete-every-other-row/2621/4 "2017-07-06T00:07:34Z")

</div>

Closed on July 6, 2017, 12:07am UTC


