# Configuring TTL mapping in JAVA API

**URL:** <https://discuss.elastic.co/t/configuring-ttl-mapping-in-java-api/16084>\
**Category:** Elasticsearch\
**Created:** [March 1, 2014, 1:31am UTC](https://discuss.elastic.co/t/configuring-ttl-mapping-in-java-api/16084 "2014-03-01T01:31:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveen\_rao](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@naveen\_rao](https://discuss.elastic.co/u/naveen_rao)\
**Post date:** [March 1, 2014, 1:31am UTC](https://discuss.elastic.co/t/configuring-ttl-mapping-in-java-api/16084/1 "2014-03-01T01:31:23Z")

</div>

Hi,

Can someone please let me know , how do we add mappings(\_mapping) to add  
ttl in java api( Just as we add via json {enabled:true }).I tried  
searching for it but cudn't find anything relevant.

Any help would be appreciated.

Regards,  
Naveen.

--  
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/54a7f336-9f06-4288-bc5a-ba691efbd195%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/54a7f336-9f06-4288-bc5a-ba691efbd195%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 3, 2014, 9:00pm UTC](https://discuss.elastic.co/t/configuring-ttl-mapping-in-java-api/16084/2 "2014-03-03T21:00:38Z")

</div>

Something like this:

```
      client.admin().indices().preparePutMapping(index)
          .setType("doc")
          .setSource(jsonBuilder().startObject()
                  .startObject("_ttl")
                      .field("enabled", true)
                  .endObject()
                  .startObject("properties")
                  .endObject()
              .endObject()
          )
          .execute()
          .actionGet();

```

--  
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/1243cec8-f9a0-4008-84c8-713d62469d7a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1243cec8-f9a0-4008-84c8-713d62469d7a%40googlegroups.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, 1:46am UTC](https://discuss.elastic.co/t/configuring-ttl-mapping-in-java-api/16084/3 "2017-07-06T01:46:03Z")

</div>


