Updating default ttl value in elasticsearch?

Hi @Rajind_Ruparathna,

let me start by pointing out that _ttl is deprecated in Elasticsearch 2.x.

Did you try to update the mapping?

Here is a complete example that worked fine for me (tested with Elasticsearch 2.3.4):

DELETE /my_index

PUT /my_index
{
  "mappings": {
    "my_type": {
      "_ttl": {
        "enabled": true,
        "default": "1m"
      }
    }
  }
}

PUT /my_index/my_type/1
{
  "text": "Will expire in 1 minute"
}

GET /my_index/my_type/1


PUT /my_index/_mapping/my_type
{
      "_ttl": {
         "enabled": true,
         "default": "24h"
      }
}

PUT /my_index/my_type/2
{
  "text": "Will expire in a day"
}

GET /my_index/my_type/2

Daniel

2 Likes