# TTL and bulk insert

**URL:** <https://discuss.elastic.co/t/ttl-and-bulk-insert/5824>\
**Category:** Elasticsearch\
**Created:** [November 9, 2011, 1:25am UTC](https://discuss.elastic.co/t/ttl-and-bulk-insert/5824 "2011-11-09T01:25:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![electic](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@electic](https://discuss.elastic.co/u/electic)\
**Post date:** [November 9, 2011, 1:25am UTC](https://discuss.elastic.co/t/ttl-and-bulk-insert/5824/1 "2011-11-09T01:25:03Z")

</div>

So, as per the document, I am doing a bulk insert. But I wanted to  
know how to use the new TTL feature. I have something like this

{"create":{"\_id":"some\_id","\_index":"documents","\_type":"document"}}  
the document json here

Where would i put the TTL. Would I put it in the document itself or  
the declaration before the document. Something like this:

{"create":{"\_id":"some\_id","\_index":"documents","\_type":"document",  
"\_ttl":"30d"}}  
the document json here

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)\
**Post date:** [November 9, 2011, 9:23am UTC](https://discuss.elastic.co/t/ttl-and-bulk-insert/5824/2 "2011-11-09T09:23:43Z")

</div>

Hey,

both should work. You can make sure the ttl was set property by querying  
your index with fields=\_ttl in your query.

---

<div class="post-metadata">

**Author:** ![electic](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@electic](https://discuss.elastic.co/u/electic)\
**Post date:** [November 10, 2011, 8:09am UTC](https://discuss.elastic.co/t/ttl-and-bulk-insert/5824/3 "2011-11-10T08:09:50Z")

</div>

Thanks!

On Nov 9, 1:23 am, Benjamin Devèze [benjamin.dev...@gmail.com](mailto:benjamin.dev...@gmail.com) wrote:

> Hey,
> 
> both should work. You can make sure the ttl was set property by querying  
> your index with fields=\_ttl in your query.

---

<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:49am UTC](https://discuss.elastic.co/t/ttl-and-bulk-insert/5824/4 "2017-07-06T03:49:13Z")

</div>

Closed on July 6, 2017, 3:49am UTC


