# \_ttl metafield in IGetResponse

**URL:** <https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885>\
**Category:** Elasticsearch\
**Created:** [August 12, 2016, 6:06am UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885 "2016-08-12T06:06:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirill\_Teplinskiy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kirill_teplinskiy/32/1517_2.png) [@Kirill\_Teplinskiy](https://discuss.elastic.co/u/Kirill_Teplinskiy)\
**Post date:** [August 12, 2016, 6:06am UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/1 "2016-08-12T06:06:13Z")

</div>

Hi everyone!

Could someone help with reading `_ttl` metafield from the response of Get API? Here is typical response containing `_ttl` field:

`{ "_index" : "attachment-v2", "_type" : "attachments", "_id" : "f2a7fcc7-0c04-45d6-8a8d-a9d604d28612", "_version" : 1, "_routing" : "Ida36e508a-9020-42e2-8c67-bb58987e7fb2", "_ttl" : 1898062282, "_parent" : "Ida36e508a-9020-42e2-8c67-bb58987e7fb2", "found" : true }`

Corresponding [GetResponse](https://github.com/elastic/elasticsearch-net/blob/9cab2174dd988fb8cf6b440fdd24d32517eab5b0/src/Nest/Document/Single/Get/GetResponse.cs) class contains fields `Type`, `Index` and so on but doesn't contain field for `_ttl`. `GetResponse.Fields` also doesn't contain `_ttl` field even if `_ttl` was included in `fields` parameter of the request.

I'm using NEST 2.4. In the NEST 1.x `_ttl` field was in the `.FieldsValues`.

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [August 12, 2016, 7:27pm UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/2 "2016-08-12T19:27:46Z")

</div>

Hello Kirill\_Teplinskiy,

The \_ttl is the per document time to live. It specifies when the document will expire/get deleted.

As of 2.0.0-beta2, this field has been deprecated.

Please, refer to [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ttl-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ttl-field.html)

Cheers

---

<div class="post-metadata">

**Author:** ![Kirill\_Teplinskiy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kirill_teplinskiy/32/1517_2.png) [@Kirill\_Teplinskiy](https://discuss.elastic.co/u/Kirill_Teplinskiy)\
**Post date:** [August 15, 2016, 6:35am UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/3 "2016-08-15T06:35:06Z")

</div>

Thanks for the answer!

I know about deprecation of `_ttl` field and the ways to avoid using `_ttl`. However, the field is still returned in the response and setting TTL is still supported by ES and NEST. Also, `_ttl` field exists in [IHit](https://github.com/elastic/elasticsearch-net/blob/be0f2a70933c41c81235e057e7076dd2b33feb39/src/Nest/Search/Search/Hits/Hit.cs#L68). Shouldn't it be in the `GetResponse` too?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 16, 2016, 7:33am UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/4 "2016-08-16T07:33:19Z")

</div>

Hey @Kirill_Teplinskiy! It looks like this and some other metadata fields were missed from `IGetResponse<T>` in the 2.x refactoring; [I've added an issue to address this.](https://github.com/elastic/elasticsearch-net/issues/2213)

In the meantime, you can work around this by deserializing the response yourself using the lowlevel client, defining a type that has the missing metafields. Let me know if you need some pointers here and I can drum up an example.

---

<div class="post-metadata">

**Author:** ![Kirill\_Teplinskiy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kirill_teplinskiy/32/1517_2.png) [@Kirill\_Teplinskiy](https://discuss.elastic.co/u/Kirill_Teplinskiy)\
**Post date:** [August 16, 2016, 9:47am UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/5 "2016-08-16T09:47:37Z")

</div>

@forloop Thanks for the answer!

Another way to work around this is using `.Search` with `.Ids` and calling `Hits.Single().Ttl` on the result.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 17, 2016, 7:00am UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/6 "2016-08-17T07:00:00Z")

</div>

That'll work too 🙂

[I've submitted a PR to get this in the next release](https://github.com/elastic/elasticsearch-net/pull/2214) 👍

---

<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 5, 2017, 10:27pm UTC](https://discuss.elastic.co/t/-ttl-metafield-in-igetresponse/57885/7 "2017-07-05T22:27:23Z")

</div>


