I have an index in elasticsearch with is occupied by some json files with respected to timestamp. I want to delete data from that index.
curl -XDELETE http://localhost:9200/index_name
Above code deletes the whole index. My requirement is to delete certain data after a time period(for example after 1 week). Could I automate the deletion process?
I tried to delete by using curator.
But I think it deletes the indexes created by timestamp
, not data with in an index. Can we use curator for delete data within an index?
It will be pleasure if I get to know that either of following would work:
References are taken from the official site of elasticsearch.
Thanks a lot in advance.
You can use the DELETE BY QUERY
API: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
Basically it will delete all the documents matching the provided query:
POST twitter/_delete_by_query
{
"query": {
"match": {
"message": "some message"
}
}
}
But the suggested way is to implement indexes for different periods (days for example) and use curator
to drop them periodically, based on the age
:
...
logs_2019.03.11
logs_2019.03.12
logs_2019.03.13
logs_2019.03.14