# Prevent Elasticsearch from purging documents based on ttl

**URL:** <https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811>\
**Category:** Elasticsearch\
**Created:** [July 19, 2017, 4:01pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811 "2017-07-19T16:01:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andiries](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@andiries](https://discuss.elastic.co/u/andiries)\
**Post date:** [July 19, 2017, 4:01pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811/1 "2017-07-19T16:01:40Z")

</div>

Hi,  
I'm having trouble with restoring data from an elasticsearch database that contains documents with a ttl of 2 days.

A customer gave us the files forming the database. The documents in there are actually older than two days so that whenever I start elasicsearch, it does a good job on purging the documents.

My question is, how can I prevent elasticsearch from doing so, because I need to analyse the data.

I know, I could probably just change the operating system date/time but I thought there must be another way?  
I already tried setting `index.ttl.disable_purge : true` in elasticsearch.yml, but that didn't work

Elasticsearch version is 2.2.0

Thanks,  
Andi

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 20, 2017, 9:14pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811/2 "2017-07-20T21:14:25Z")

</div>

`disable_purge` is a per-index setting, so you'll need to start Elasticsearch and then call an UpdateSettings API for the desired indices:

```auto
PUT /my_index/_settings
{
  "index.ttl.disable_purge": true
}

```

Alternatively, you could update the ttl interval to something very large so it doesn't run in the near future:

```auto
PUT /_cluster/settings
{
    "persistent" : {
        "indices.ttl.interval" : 999999999999
    }
}

```

Note: I think these are correct, but I'm going from memory since I haven't worked with 2.x in a long time 🙂

---

<div class="post-metadata">

**Author:** ![andiries](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@andiries](https://discuss.elastic.co/u/andiries)\
**Post date:** [July 21, 2017, 6:18am UTC](https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811/3 "2017-07-21T06:18:57Z")

</div>

Hi,

thanks for your answer, I'll give it a try.  
But my guess is, that before I'm even able to make the PUT request, elasticsearch has already purged the documents right at startup.  
I'll let you know

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 21, 2017, 1:25pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811/4 "2017-07-21T13:25:45Z")

</div>

Yeah, I'm not sure how quickly the purge process boots up. You may have to resort to system time hacks 😕

---

<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:** [August 18, 2017, 1:26pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-from-purging-documents-based-on-ttl/93811/5 "2017-08-18T13:26:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
