# TTL value must be \> 0. Illegal value provided

**URL:** <https://discuss.elastic.co/t/ttl-value-must-be-0-illegal-value-provided/19088>\
**Category:** Elasticsearch\
**Created:** [August 5, 2014, 9:08am UTC](https://discuss.elastic.co/t/ttl-value-must-be-0-illegal-value-provided/19088 "2014-08-05T09:08:37Z")\
**Posts on this page:** 3\
**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 5, 2014, 9:08am UTC](https://discuss.elastic.co/t/ttl-value-must-be-0-illegal-value-provided/19088/1 "2014-08-05T09:08:37Z")

</div>

I recently recieved some exceptions in my log while updating documents  
into my index.

org.elasticsearch.ElasticSearchIllegalArgumentException: TTL value must be

> 1. Illegal value provided [-17810]  
> at  
> org.elasticsearch.action.index.IndexRequest.ttl(IndexRequest.java:291)  
> at  
> org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:153)  
> at  
> org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:60)  
> at  
> org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:183)  
> at  
> org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:179)  
> at  
> org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:63)  
> at  
> org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction$1.run(TransportInstanceSingleOperationAction.java:192)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)  
> at java.lang.Thread.run(Thread.java:662)

I insert/update a lot of documents into Elasticsearch daily at 3:00 am by  
using an UPSERT command.  
All of these documents (offers) have a TTL of 30 days (set using a template)

client.prepareUpdate(indexName, documentTypeName, offer.internal\_id)  
.setDoc(offer)  
.setUpsert(newOffer)

I don't understand why I receive these errors. The expired documents  
_should already be removed_ by elasticsearch right? Any help or pointers  
are much appreciated.

Questions:

1. I insert a document with a TTL of 30 days. I update this document daily.  
Will the TTL be reset to 30 days on every update or will it just decrease  
no matter what I do with the document.?
2. I found a similar topic  
[Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/ifvWZJjQuvU/cZzkhfmg6YoJ)  
with Github issue  
[Updating document with expired \_ttl results in "TTL value must be \> 0. Illegal value provided" error · Issue #3256 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3256). This case  
describes a race condition while updating a document right after the TTL  
expired. In my case however documents are updated daily so expired document  
should already be removed right?
3. is there a way (e.g. a query) to tell what documents are about to expire  
/ or are expired and need to be removed by elasticsearch.
4. When query elasticsearch for document which have a TTL \< 0 , it returns  
no documents. How come? This is the query I execute:

{  
"fields": ["\_ttl"],

"query": {  
"match\_all": {}  
},  
"filter": {  
"range": {  
"\_ttl": {  
"lte": 1  
}  
}  
}  
}

--  
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/5c671844-94ba-4be1-a94c-d6053f01d04a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5c671844-94ba-4be1-a94c-d6053f01d04a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 5, 2014, 9:35am UTC](https://discuss.elastic.co/t/ttl-value-must-be-0-illegal-value-provided/19088/2 "2014-08-05T09:35:32Z")

</div>

forgot to mention I'm using version 0.90.5

Op dinsdag 5 augustus 2014 11:08:37 UTC+2 schreef Dennis de Boer:

> I recently recieved some exceptions in my log while updating documents  
> into my index.
> 
> org.elasticsearch.ElasticSearchIllegalArgumentException: TTL value must be
> 
> > 1. Illegal value provided [-17810]  
> > at  
> > org.elasticsearch.action.index.IndexRequest.ttl(IndexRequest.java:291)  
> > at  
> > org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:153)  
> > at  
> > org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:60)  
> > at  
> > org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:183)  
> > at  
> > org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:179)  
> > at  
> > org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:63)  
> > at  
> > org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction$1.run(TransportInstanceSingleOperationAction.java:192)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)  
> > at java.lang.Thread.run(Thread.java:662)
> 
> I insert/update a lot of documents into Elasticsearch daily at 3:00 am by  
> using an UPSERT command.  
> All of these documents (offers) have a TTL of 30 days (set using a  
> template)
> 
> client.prepareUpdate(indexName, documentTypeName, offer.internal\_id)  
> .setDoc(offer)  
> .setUpsert(newOffer)
> 
> I don't understand why I receive these errors. The expired documents  
> _should already be removed_ by elasticsearch right? Any help or pointers  
> are much appreciated.
> 
> Questions:
> 
> 1. I insert a document with a TTL of 30 days. I update this document  
> daily. Will the TTL be reset to 30 days on every update or will it just  
> decrease no matter what I do with the document.?
> 2. I found a similar topic  
> [Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/ifvWZJjQuvU/cZzkhfmg6YoJ)  
> with Github issue  
> [Updating document with expired \_ttl results in "TTL value must be \> 0. Illegal value provided" error · Issue #3256 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3256). This case  
> describes a race condition while updating a document right after the TTL  
> expired. In my case however documents are updated daily so expired document  
> should already be removed right?
> 3. is there a way (e.g. a query) to tell what documents are about to  
> expire / or are expired and need to be removed by elasticsearch.
> 4. When query elasticsearch for document which have a TTL \< 0 , it returns  
> no documents. How come? This is the query I execute:
> 
> {  
> "fields": ["\_ttl"],
> 
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "range": {  
> "\_ttl": {  
> "lte": 1  
> }  
> }  
> }  
> }

--  
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/ed71b65f-f77d-4b39-b9b3-4cab06d5be1a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ed71b65f-f77d-4b39-b9b3-4cab06d5be1a%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/ttl-value-must-be-0-illegal-value-provided/19088/3 "2017-07-06T01:10:48Z")

</div>


