elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.94k stars 24.74k forks source link

Delete elasticsearch old indices based on created_time #39235

Closed naithagoni closed 5 years ago

naithagoni commented 5 years ago

I have a question regarding deleting the indices by date_formant(created date). I am using elasticsearch 6.4

For example, I have a indices structure as below:

logstash-2019.03.21 logstash-2019.03.20 logstash-2019.03.15 logstash-2019.03.10 logstash-2019.03.12 I want to delete the indices (not the documents) let say 3 days older`

NOTE: I have also used different ways, for example.

using date math: query {index: '%3Clogstash-%7Bnow-3d%7D%3E'}. this way, it only apply for the single index. 2.

let query = { index: 'logstash*', headers: null, body: { query: { range: { '@timestamp': { lt: 'now-2d' }, }, }, }, }; this deletes the documents not the indices.

  1. I am not(do not want) using Elasticsearch-curator.
jasontedor commented 5 years ago

Thanks very much for your interest in Elasticsearch.

This appears to be a user question, and we'd like to direct these kinds of things to the forums. If you can stop by there, we'd appreciate it. This allows us to use GitHub for verified bug reports, feature requests, and pull requests.

There's an active community in the forums that should be able to help get an answer to your question. As such, I hope you don't mind that I close this.