Remove or delete old data from elastic search

sri picture sri · Dec 9, 2015 · Viewed 24.2k times · Source

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

Answer

ChintanShah25 picture ChintanShah25 · Dec 9, 2015

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