Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove or delete old data from elastic search

Tags:

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

like image 336
sri Avatar asked Dec 09 '15 03:12

sri


Video Answer


2 Answers

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

like image 80
ChintanShah25 Avatar answered Sep 22 '22 09:09

ChintanShah25


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.

like image 41
Ali Nikneshan Avatar answered Sep 20 '22 09:09

Ali Nikneshan