# Problem with TTL

**URL:** <https://discuss.elastic.co/t/problem-with-ttl/10924>\
**Category:** Elasticsearch\
**Created:** [February 27, 2013, 12:55pm UTC](https://discuss.elastic.co/t/problem-with-ttl/10924 "2013-02-27T12:55:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denica\_Gencheva](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Denica\_Gencheva](https://discuss.elastic.co/u/Denica_Gencheva)\
**Post date:** [February 27, 2013, 12:55pm UTC](https://discuss.elastic.co/t/problem-with-ttl/10924/1 "2013-02-27T12:55:24Z")

</div>

Hi,  
I'm trying to set TTL on a document as following:

1. Create a new document:  
_curl "[http://MYHOST:9200/deni\_index/deni\_type/1?pretty=true](http://MYHOST:9200/deni_index/deni_type/1?pretty=true)" -d  
'{"comment":"test"}'_  
_{_

- "ok" : true,\*

- "\_index" : "deni\_index",\*

- "\_type" : "deni\_type",\*

- "\_id" : "1",\*

- "\_version" : 1\*  
\*} \*

- "ok" : true,\*

- "acknowledged" : true\*  
_}_

- 
- 
  1. Check if the property is set correct:  
_curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true)_  
_{_

- "deni\_type" : {\*

- "properties" : {\*

- 

```
 "comment" : {*

```

- 

```
   "type" : "string"*

```

- 

```
 }*

```

- }\*

- }\*  
_}_

The "\_ttl" : { "enabled" : true } is missing. If I set a default value:  
\*curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true) -d  
'{"deni\_type" : { "\_ttl" : { "enabled" : true, "default":"30000" }}}'  
\*  
_{_

- "ok" : true,\*
- "acknowledged" : true\*  
_}_  
I see only the "default", not "enabled".  
_curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true)_  
_{_
- "deni\_type" : {\*
- "\_ttl" : {\*
- 

```
 "default" : 30000*

```

- },\*
- "properties" : {\*
- 

```
 "comment" : {*

```

- 

```
   "type" : "string"*

```

- 

```
 }*

```

- }\*
- }\*  
_}_
- 
- 

If I add new documents with TTL (curl  
"[http://MYHOST:9200/deni\_index/deni\_type/2?ttl=30000](http://MYHOST:9200/deni_index/deni_type/2?ttl=30000)) the document don't  
expired after 30 sec.  
Could you please tell me what I'm doing wrong?  
The version of the elastic search is 0.20.4. The documentation I read is:  
[http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html](http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html)

Regards, Denitsa  
\*  
\*  
\*  
\*

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [March 3, 2013, 6:11pm UTC](https://discuss.elastic.co/t/problem-with-ttl/10924/2 "2013-03-03T18:11:47Z")

</div>

It's possible to enable TTL only during mapping creation. After mapping is  
created, you can only change the default value. In your case, you create  
mappings first (by indexing the document) and only then try enable TTL.  
That's not supported at the moment.

On Wednesday, February 27, 2013 7:55:24 AM UTC-5, Denica Gencheva wrote:

> Hi,  
> I'm trying to set TTL on a document as following:
> 
> 1. Create a new document:  
> _curl "[http://MYHOST:9200/deni\_index/deni\_type/1?pretty=true](http://MYHOST:9200/deni_index/deni_type/1?pretty=true)" -d  
> '{"comment":"test"}'_  
> _{_
> 
> - "ok" : true,\*
> 
> - "\_index" : "deni\_index",\*
> 
> - "\_type" : "deni\_type",\*
> 
> - "\_id" : "1",\*
> 
> - "\_version" : 1\*  
> \*} \*
> 
> - "ok" : true,\*
> 
> - "acknowledged" : true\*  
> _}_
> 
> - 
> - 
> 1. Check if the property is set correct:  
> _curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true)_  
> _{_
> 
> - "deni\_type" : {\*
> 
> - "properties" : {\*
> 
> - 
> 
> ```
> "comment" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "string"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - }\*
> 
> - }\*  
> _}_
> 
> The "\_ttl" : { "enabled" : true } is missing. If I set a default value:  
> \*curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true) -d  
> '{"deni\_type" : { "\_ttl" : { "enabled" : true, "default":"30000" }}}'  
> \*  
> _{_
> 
> - "ok" : true,\*
> - "acknowledged" : true\*  
> _}_  
> I see only the "default", not "enabled".  
> _curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true)_  
> _{_
> - "deni\_type" : {\*
> - "\_ttl" : {\*
> - 
> 
> ```
> "default" : 30000*
> 
> ```
> 
> - },\*
> - "properties" : {\*
> - 
> 
> ```
> "comment" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "string"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - }\*
> - }\*  
> _}_
> - 
> - 
> 
> If I add new documents with TTL (curl "  
> [http://MYHOST:9200/deni\_index/deni\_type/2?ttl=30000](http://MYHOST:9200/deni_index/deni_type/2?ttl=30000)) the document don't  
> expired after 30 sec.  
> Could you please tell me what I'm doing wrong?  
> The version of the Elasticsearch is 0.20.4. The documentation I read is:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html)
> 
> Regards, Denitsa  
> \*  
> \*  
> \*  
> \*

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Dusty\_Doris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dusty_doris/32/2441_2.png) [@Dusty\_Doris](https://discuss.elastic.co/u/Dusty_Doris)\
**Post date:** [March 14, 2013, 6:35pm UTC](https://discuss.elastic.co/t/problem-with-ttl/10924/3 "2013-03-14T18:35:53Z")

</div>

I'm curious if that functionality is going to be added. (ability to add  
ttl to an existing mapping)

So, for now one should create a new index with TTL enabled and copy the old  
index to it, right?

On Sunday, March 3, 2013 11:11:47 AM UTC-7, Igor Motov wrote:

> It's possible to enable TTL only during mapping creation. After mapping is  
> created, you can only change the default value. In your case, you create  
> mappings first (by indexing the document) and only then try enable TTL.  
> That's not supported at the moment.
> 
> On Wednesday, February 27, 2013 7:55:24 AM UTC-5, Denica Gencheva wrote:
> 
> > Hi,  
> > I'm trying to set TTL on a document as following:
> > 
> > 1. Create a new document:  
> > _curl "[http://MYHOST:9200/deni\_index/deni\_type/1?pretty=true](http://MYHOST:9200/deni_index/deni_type/1?pretty=true)" -d  
> > '{"comment":"test"}'_  
> > _{_
> > 
> > - "ok" : true,\*
> > 
> > - "\_index" : "deni\_index",\*
> > 
> > - "\_type" : "deni\_type",\*
> > 
> > - "\_id" : "1",\*
> > 
> > - "\_version" : 1\*  
> > \*} \*
> > 
> > - "ok" : true,\*
> > 
> > - "acknowledged" : true\*  
> > _}_
> > 
> > - 
> > - 
> > 1. Check if the property is set correct:  
> > _curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true)_  
> > _{_
> > 
> > - "deni\_type" : {\*
> > 
> > - "properties" : {\*
> > 
> > - 
> > 
> > ```
> > "comment" : {*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "type" : "string"*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > }*
> > 
> > ```
> > 
> > - }\*
> > 
> > - }\*  
> > _}_
> > 
> > The "\_ttl" : { "enabled" : true } is missing. If I set a default value:  
> > \*curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true) -d  
> > '{"deni\_type" : { "\_ttl" : { "enabled" : true, "default":"30000" }}}'  
> > \*  
> > _{_
> > 
> > - "ok" : true,\*
> > - "acknowledged" : true\*  
> > _}_  
> > I see only the "default", not "enabled".  
> > _curl [http://MYHOST:9200/deni\_index/deni\_type/\_mapping?pretty=true](http://MYHOST:9200/deni_index/deni_type/_mapping?pretty=true)_  
> > _{_
> > - "deni\_type" : {\*
> > - "\_ttl" : {\*
> > - 
> > 
> > ```
> > "default" : 30000*
> > 
> > ```
> > 
> > - },\*
> > - "properties" : {\*
> > - 
> > 
> > ```
> > "comment" : {*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "type" : "string"*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > }*
> > 
> > ```
> > 
> > - }\*
> > - }\*  
> > _}_
> > - 
> > - 
> > 
> > If I add new documents with TTL (curl "  
> > [http://MYHOST:9200/deni\_index/deni\_type/2?ttl=30000](http://MYHOST:9200/deni_index/deni_type/2?ttl=30000)) the document don't  
> > expired after 30 sec.  
> > Could you please tell me what I'm doing wrong?  
> > The version of the Elasticsearch is 0.20.4. The documentation I read  
> > is: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html)
> > 
> > Regards, Denitsa  
> > \*  
> > \*  
> > \*  
> > \*

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:46am UTC](https://discuss.elastic.co/t/problem-with-ttl/10924/4 "2017-07-06T02:46:23Z")

</div>


