# Total TTL confusion

**URL:** <https://discuss.elastic.co/t/total-ttl-confusion/19114>\
**Category:** Elasticsearch\
**Created:** [August 6, 2014, 10:33am UTC](https://discuss.elastic.co/t/total-ttl-confusion/19114 "2014-08-06T10:33:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis\_de\_Boer](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@Dennis\_de\_Boer](https://discuss.elastic.co/u/Dennis_de_Boer)\
**Post date:** [August 6, 2014, 10:33am UTC](https://discuss.elastic.co/t/total-ttl-confusion/19114/1 "2014-08-06T10:33:03Z")

</div>

I'm getting regular TTL exceptions in my elasticsearch setup during  
updating documents. I want to figure out how exactly TLL works.  
The more I read about it, the more confusing it gets.

I have several questions, hope anyone is willing to answer them:

\*\*\* Using elasticsearch 0.90.5  
\*\*\* In my mapping I set the -tll to 30 days using "\_ttl": { "enabled":  
true, "default": "30d" }. I can confirm this works by querying the \_mapping  
endpoint. \*\*\*

1. when I update an existing document, will the ttl be updated or not?  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/docs-update.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/docs-update.html)  
and also [https://github.com/elasticsearch/elasticsearch/issues/3180](https://github.com/elasticsearch/elasticsearch/issues/3180) make  
reference to the fact that the TTL will not be updated when you do an  
update request. Which makes sense since you basically do a delete and  
reindex for that document. However, on  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/mapping-ttl-field.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/mapping-ttl-field.html)  
it states :

_Note that the expiration procedure handle versioning properly so if a  
document is updated between the collection of documents to expire and the  
delete order, the document won’t be deleted._

Do the two resources conflict each other?

1. Since I have a default ttl of 30days, I would expect my documents to  
have a ttl of 2592000000ms at most. However, when I query for all the TTL's  
in my index (using a statistical facet for example), the minum value I get  
is 1407373291910ms, which is over 44 years!  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/mapping-ttl-field.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/mapping-ttl-field.html)  
states that

_If no default is set and no \_ttl value is given then the document has an  
infinite \_ttl and will not expire._

Is this what happened here? Does the update query not (correctly / at all)  
set the ttl?

1. 

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/docs-index\_.html#index-ttl](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/docs-index_.html#index-ttl)  
states:

_The expiration date that will be set for a document with a provided ttl is  
relative to the timestamp of the document_

However; I have NOT set a timestamp OR enabled it in my mapping. As far as  
I know my documents do not have any timestamp.  
How does Elasticsearch compute the expiration date on these documents?

Any help would be much appreciated here . Thank you!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7104e6f2-83a8-4e74-a7e8-c8d718c196b7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7104e6f2-83a8-4e74-a7e8-c8d718c196b7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:10am UTC](https://discuss.elastic.co/t/total-ttl-confusion/19114/2 "2017-07-06T01:10:29Z")

</div>


