# Can't delete old indices older than 21 days

**URL:** https://discuss.elastic.co/t/cant-delete-old-indices-older-than-21-days/253586
**Category:** Elasticsearch
**Created:** [October 28, 2020, 4:12pm UTC](https://discuss.elastic.co/t/cant-delete-old-indices-older-than-21-days/253586 "2020-10-28T16:12:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yys2000](https://avatars.discourse-cdn.com/v4/letter/y/97f17d/32.png) [@yys2000](https://discuss.elastic.co/u/yys2000)
#### Post date: [October 28, 2020, 4:12pm UTC](https://discuss.elastic.co/t/cant-delete-old-indices-older-than-21-days/253586/1 "2020-10-28T16:12:16Z")

</div>

Hi,

I ran this in Kibana to delete the indices older than 21 days:  
POST monstache.\*/\_delete\_by\_query  
{  
"query": {  
"range": {  
"@timestamp": {  
"lte": "now-21d"  
}  
}  
}  
}

After ran it, I performed indices search and got lots of old indices returned:  
yellow open monstache.stats.2020-07-07 Lz6PBgmAQ\_Wi6S5Sf5d\_Yg 5 1 2880 0 682.9kb 682.9kb  
yellow open monstache.stats.2020-07-08 \_yyFXGfYQpmw6qlDPohb8Q 5 1 2880 0 803.1kb 803.1kb  
yellow open monstache.stats.2020-07-09 pEVHOzkVSGeftJduUTSIFg 5 1 2880 0 716.8kb 716.8kb  
yellow open monstache.stats.2020-07-10 sAvO\_gWwREKVfY4TogBTvQ 5 1 2880 0 784.1kb 784.1kb  
yellow open monstache.stats.2020-07-11 uu\_mPyCsSWymiW7P0MsZJw 5 1 2880 0 786kb 786kb  
yellow open monstache.stats.2020-07-12 mKYu0MlYRkWk8IuAz1yMiw 5 1 2880 0 713kb 713kb

I noticed that all these old indices are still in open status.  
My question is why I can't delete these old indices?

thanks  
👍

---

<div class="post-metadata">

### Author: ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)
#### Post date: [October 29, 2020, 7:46am UTC](https://discuss.elastic.co/t/cant-delete-old-indices-older-than-21-days/253586/2 "2020-10-29T07:46:50Z")

</div>

Hello David,

What are you trying to do? [Delete by Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html) does not delete the indices - it deletes the documents within while the indizes are kept. If you really want to delete the index do:

```auto
DELETE /monstache.stats.2020-07-07

```

Which version do you have? If you want to regularily delete old indizes [ILM](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html) might be the right way for you as it allows to define when indizes should be deleted and more.

Best regards  
Wolfram

---

<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: [November 26, 2020, 7:47am UTC](https://discuss.elastic.co/t/cant-delete-old-indices-older-than-21-days/253586/3 "2020-11-26T07:47:08Z")

</div>

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