# How can I delete all indices that don't have documents?

**URL:** <https://discuss.elastic.co/t/how-can-i-delete-all-indices-that-dont-have-documents/258571>\
**Category:** Elasticsearch\
**Created:** [December 14, 2020, 11:40am UTC](https://discuss.elastic.co/t/how-can-i-delete-all-indices-that-dont-have-documents/258571 "2020-12-14T11:40:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahalabobis](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mahalabobis](https://discuss.elastic.co/u/mahalabobis)\
**Post date:** [December 14, 2020, 11:40am UTC](https://discuss.elastic.co/t/how-can-i-delete-all-indices-that-dont-have-documents/258571/1 "2020-12-14T11:40:49Z")

</div>

How can I delete all Elasticsearch that have no documents within? Also, is this safe ? I mean if an index has no documents then it's practically useless right?

---

<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:** [December 15, 2020, 12:35am UTC](https://discuss.elastic.co/t/how-can-i-delete-all-indices-that-dont-have-documents/258571/2 "2020-12-15T00:35:09Z")

</div>

Unless you have something using them, then yes you can delete them as they are just wasting resources.

Use the delete API endpoint - [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html)

---

<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:** [January 12, 2021, 12:35am UTC](https://discuss.elastic.co/t/how-can-i-delete-all-indices-that-dont-have-documents/258571/3 "2021-01-12T00:35:25Z")

</div>

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