Delete index after 1 day if empty and after n days if not empty

Hi, we use daily indices and currently use an ILM policy to delete indices after n days. However, we have some indices each day that don't end up having documents and would like to delete those after 1 day instead of keeping them around for the full n days.

Can we specify an ILM policy to delete an index after 1 day if it's empty but keep it for n days if it isn't empty?

Thanks!

No, this is not possible, ILM works on entire indices, and for the DELETE phase it doesn't matter if they have documents or not, they will be deleted by age.

write small bash script or python script.
check count of record in index and if zero delete.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html

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