# Remove old document versions

**URL:** <https://discuss.elastic.co/t/remove-old-document-versions/133126>\
**Category:** Elasticsearch\
**Created:** [May 24, 2018, 10:58am UTC](https://discuss.elastic.co/t/remove-old-document-versions/133126 "2018-05-24T10:58:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atom/32/34758_2.png) [@atom](https://discuss.elastic.co/u/atom)\
**Post date:** [May 24, 2018, 10:58am UTC](https://discuss.elastic.co/t/remove-old-document-versions/133126/1 "2018-05-24T10:58:41Z")

</div>

Hi,  
i am currently writing a script which makes use of update by query.  
I am trying to remove a field in all indices and documents older than 7 days.  
I can see in Kibana that it is working. But i think the information are still stored in elasticserach because i heard that update by query creates a new version of the updated document.  
My questions are:

1. Is this correct?
2. If yes, how can i remove older versions of document or how can i update without creating new versions of documents.

Regards, Ahmet

---

<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:** [May 24, 2018, 2:49pm UTC](https://discuss.elastic.co/t/remove-old-document-versions/133126/2 "2018-05-24T14:49:09Z")

</div>

Internally, updates do indeed create a new version of the document and then overwrites it. The old document is marked for deletion and eventually purged.

Practically, you don't need to worry about this... it's all an internal implementation detail. From the application's point of view, once updated the old version of the document is not accessible anymore. Internally it will be cleaned up at some point and removed.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atom/32/34758_2.png) [@atom](https://discuss.elastic.co/u/atom)\
**Post date:** [May 24, 2018, 4:04pm UTC](https://discuss.elastic.co/t/remove-old-document-versions/133126/3 "2018-05-24T16:04:52Z")

</div>

Thank you very much 👍🙂

---

<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:** [June 21, 2018, 4:05pm UTC](https://discuss.elastic.co/t/remove-old-document-versions/133126/4 "2018-06-21T16:05:03Z")

</div>

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