# Reading ttl setting from a file

**URL:** <https://discuss.elastic.co/t/reading-ttl-setting-from-a-file/8896>\
**Category:** Elasticsearch\
**Created:** [August 30, 2012, 2:16pm UTC](https://discuss.elastic.co/t/reading-ttl-setting-from-a-file/8896 "2012-08-30T14:16:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![emj11](https://avatars.discourse-cdn.com/v4/letter/e/ecc23a/32.png) [@emj11](https://discuss.elastic.co/u/emj11)\
**Post date:** [August 30, 2012, 2:16pm UTC](https://discuss.elastic.co/t/reading-ttl-setting-from-a-file/8896/1 "2012-08-30T14:16:07Z")

</div>

Hi, I am currently reading a mapping from a file, my call to create the  
index and mapping is this:

client.admin().indices().create(new  
CreateIndexRequest(INDEX).settings(settingsBuilder).mapping(CHAT\_TYPE,  
chat).mapping(MUC\_TYPE, muc)).actionGet();

my 'chat' string (mapping) has the following:  
{  
"chat" : {  
"properties":{  
"\_timestamp" : {  
"enabled" : true  
},

"from\_jid":{"index":"not\_analyzed","type":"string"},

"to\_jid":{"index":"not\_analyzed","type":"string"},  
"\_ttl" : { "enabled" : "true", "default" : "2m" },  
......

this fails on the ttl line stating:  
org.elasticsearch.index.mapper.MapperParsingException: mapping [chat]  
at  
org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:262)  
at  
org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:211)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)  
_Caused by: org.elasticsearch.index.mapper.MapperParsingException: No type  
specified for property [\_ttl]_  
at  
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:253)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)  
at  
org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:161)  
at  
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:271)  
at org.elasticsearch.index.mapper.MapperService.add(MapperService.java:174)  
at  
org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:259)  
... 4 more

It seems the \_ttl is not being recognized as an internal field.....

Also, if i enable ttl for a mapping, does ttl need to be enabled on the  
cluster level as well? I'm not sure if this is even possible. I would  
like to set ttl on the index level rather than a cluster or doc level.

Thanks.

--

---

<div class="post-metadata">

**Author:** ![emj11](https://avatars.discourse-cdn.com/v4/letter/e/ecc23a/32.png) [@emj11](https://discuss.elastic.co/u/emj11)\
**Post date:** [August 30, 2012, 3:20pm UTC](https://discuss.elastic.co/t/reading-ttl-setting-from-a-file/8896/2 "2012-08-30T15:20:26Z")

</div>

Additional info...I am running ES v0.19.8 and I am trying to set ttl from a  
transport client.

On Thursday, August 30, 2012 10:16:07 AM UTC-4, emj11 wrote:

> Hi, I am currently reading a mapping from a file, my call to create the  
> index and mapping is this:
> 
> client.admin().indices().create(new  
> CreateIndexRequest(INDEX).settings(settingsBuilder).mapping(CHAT\_TYPE,  
> chat).mapping(MUC\_TYPE, muc)).actionGet();
> 
> my 'chat' string (mapping) has the following:  
> {  
> "chat" : {  
> "properties":{  
> "\_timestamp" : {  
> "enabled" : true  
> },
> 
> "from\_jid":{"index":"not\_analyzed","type":"string"},
> 
> "to\_jid":{"index":"not\_analyzed","type":"string"},  
> "\_ttl" : { "enabled" : "true", "default" : "2m" },  
> ......
> 
> this fails on the ttl line stating:  
> org.elasticsearch.index.mapper.MapperParsingException: mapping [chat]  
> at  
> org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:262)  
> at  
> org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:211)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)  
> _Caused by: org.elasticsearch.index.mapper.MapperParsingException: No  
> type specified for property [\_ttl]_  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:253)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)  
> at  
> org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:161)  
> at  
> org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:271)  
> at org.elasticsearch.index.mapper.MapperService.add(MapperService.java:174)  
> at  
> org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:259)  
> ... 4 more
> 
> It seems the \_ttl is not being recognized as an internal field.....
> 
> Also, if i enable ttl for a mapping, does ttl need to be enabled on the  
> cluster level as well? I'm not sure if this is even possible. I would  
> like to set ttl on the index level rather than a cluster or doc level.
> 
> Thanks.

--

---

<div class="post-metadata">

**Author:** ![emj11](https://avatars.discourse-cdn.com/v4/letter/e/ecc23a/32.png) [@emj11](https://discuss.elastic.co/u/emj11)\
**Post date:** [September 10, 2012, 6:32pm UTC](https://discuss.elastic.co/t/reading-ttl-setting-from-a-file/8896/3 "2012-09-10T18:32:03Z")

</div>

> bump....

how is the community assigning ttl for documents? Are you setting it at  
the mapping level or the document level?

--

---

<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, 3:13am UTC](https://discuss.elastic.co/t/reading-ttl-setting-from-a-file/8896/4 "2017-07-06T03:13:18Z")

</div>


