sri
sri

Reputation: 341

Remove or delete old data from elastic search

How to remove old data from elastic search index as the index has large amount of data being inserted every day.

Upvotes: 26

Views: 40139

Answers (3)

Atif Hussain
Atif Hussain

Reputation: 898

If you are using time-based indices, that should be something like:

curl -XDELETE http://localhost:9200/test-2017-06

Upvotes: 0

Ali Nikneshan
Ali Nikneshan

Reputation: 3502

Split data to daily indexes and use alias as old index name. then Delete the each index daily. just as logstash:

Daily indices :logstash-20151011,logstash-20151012,logstash-20151013.

Full Alias: logstash

Then daily delete last index.

Upvotes: 12

ChintanShah25
ChintanShah25

Reputation: 12672

You can do that with delete by query plugin.

Assuming you have some timestamp or creation date field in your index, your query would look something like this

DELETE /your_index/your_type/_query
{
  "query": {
    "range": {
      "timestamp": {
        "lte": "now-10y"
      }
    }
  }
}

This will delete records older than 10 years.

I hope this helps

Upvotes: 23

Related Questions