ILM does support on document level in elasticsearch?

Viewed 28

I have created policy and applied policy on indices . This policy allows us to set a expiry time for a document. Once the time has past, the expired documents are deleted.

Is it possible with latest version of Elasticsearch ?

1 Answers

As far as I know ILM deletes the entire index and criteria will be the duration of days since the index has been created. If you need to delete a specific document I feel you will need to leverage API to implement this. You can setup a cronjob which uses the below script to delete a specific doc.

curl -k -X POST "https://USERNAME:PASSWORD@localhost:9200/test/_delete_by_query?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "@timestamp": {
              "lt": "now-30d"
            }
          }
        }
      ]
    }
  }
 }

Reference : https://discuss.elastic.co/t/automatically-delete-older-documents/247078/9

Related