I am using elasticsearch 2.2.0. I have a requirement wherein I have to delete certain indices, which are created on a day-to-day basis, based on two different dates.
(format - abc-xyz-yyyy-mm-dd)
For e.g. - There are 100 indices which are created between 2021-01-01 and 2021-04-10. How do I delete the indices that were created between 2021-02-01 and 2021-02-21? I should only delete the indices that begin with abc-xyz.
Can anyone help me on this? I am relatively new to ES.
Elasticsearch Curator might be able to this for you - Curator Reference [8.0] | Elastic.
You should really upgrade, urgently.
2.X has been EOL for quite a long, long time, and latest is 7.14.
Is there any way to delete the indices for my requirement using the delete API?
Only if you want to do something like curl -H "Content-Type: application/json" -XDELETE 0:9200/abc-xyz-2021-02-*
.
Otherwise just whip up a bash for loop with a counter to cover the range you need.
Thanks Mark, I used the for loop procedure and it worked, but is there any way to check if an index exists and only then delete it in the for loop?
If you script that yourself, yes.
But if a specific index doesn't exist it cannot be deleted and Elasticsearch will reject the request.
could you please tell me how to check if an index exists?
Exists API | Elasticsearch Guide [7.14] | Elastic is the best.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.