_ttl attribute not taken into account


(Antoine Brun) #1

Hello,

I have implemented a simple cache with ES.
Basically I rely on _ttl to make sure that the cache is cleaned up automatically.
below is a partial view of the doc stored in the cache.
As you can see: _ttl=5d and the date of the doc is 2015-06-30 which is more that 5 days old.

Any idea why the doc was not deleted from the index?

Antoine

{
"_index": "ubilogs-ncs-15.2.2_cache",
"_type": "cache",
"_id": "AU5E8nqFbXvxIKWU75lr",
"_version": 1,
"_score": null,
"_source": {
    "_ttl": "5d",
    "device_id": "NTT1141",
    "msg_id": "000000585107",
    "content": {
        "disk": {
            "date": "2015-06-30",
            "time": "23:30:51",
           "msg_id": "000000585107",
           "device_id": "FVVM020000038360",
            "policy": "to_MSActivator",
  ...

(Magnus B├Ąck) #2

Have you enabled TTL in the mapping?

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ttl-field.html


(Colin Goodheart-Smithe) #3

The _ttl field needs to be used with the _timestamp field. This is the field that it looks at to determine the expiry time.Are you setting the _timestamp in your documents? See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-ttl for more information.


(system) #4