# How to delete the records older than certain time using elastic java rest client

**URL:** https://discuss.elastic.co/t/how-to-delete-the-records-older-than-certain-time-using-elastic-java-rest-client/342960
**Category:** Elasticsearch
**Created:** [September 13, 2023, 1:52pm UTC](https://discuss.elastic.co/t/how-to-delete-the-records-older-than-certain-time-using-elastic-java-rest-client/342960 "2023-09-13T13:52:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tukaram](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tukaram/32/118944_2.png) [@Tukaram](https://discuss.elastic.co/u/Tukaram)
#### Post date: [September 13, 2023, 1:52pm UTC](https://discuss.elastic.co/t/how-to-delete-the-records-older-than-certain-time-using-elastic-java-rest-client/342960/1 "2023-09-13T13:52:11Z")

</div>

Hi,

I am looking to delete all the records older than 1 month or so(in bulk). How to get this done using java restclient.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [September 13, 2023, 3:27pm UTC](https://discuss.elastic.co/t/how-to-delete-the-records-older-than-certain-time-using-elastic-java-rest-client/342960/2 "2023-09-13T15:27:18Z")

</div>

That'd be very inefficient. Instead you should use time based indices and just drop the indices which contains data older than one month.

---

<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: [October 11, 2023, 3:28pm UTC](https://discuss.elastic.co/t/how-to-delete-the-records-older-than-certain-time-using-elastic-java-rest-client/342960/3 "2023-10-11T15:28:16Z")

</div>

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