# Updating documents - immutability

**URL:** <https://discuss.elastic.co/t/updating-documents-immutability/266041>\
**Category:** Elasticsearch\
**Created:** [March 3, 2021, 2:16am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041 "2021-03-03T02:16:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishekc92](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@abhishekc92](https://discuss.elastic.co/u/abhishekc92)\
**Post date:** [March 3, 2021, 2:16am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041/1 "2021-03-03T02:16:42Z")

</div>

Hi, I have a use case where a document can be updated or nested entries added to it over time. I get that documents are technically immutable and a new version is created, with the older one being soft deleted. Will this storage be restored in the background for new documents coming in, without manually intervening? If so, how often does this process happen? If it matters, I'm about the AWS managed Es.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 3, 2021, 2:23am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041/2 "2021-03-03T02:23:24Z")

</div>

> [@abhishekc92](#):
>
> Will this storage be restored in the background for new documents coming in, without manually intervening?

Can you clarify this, it's not really clear what you mean.

---

<div class="post-metadata">

**Author:** ![abhishekc92](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@abhishekc92](https://discuss.elastic.co/u/abhishekc92)\
**Post date:** [March 3, 2021, 2:30am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041/3 "2021-03-03T02:30:09Z")

</div>

Well I'm fairly new to elastic, and am doing some capacity planning/sizing. My question is along the lines of [https://discuss.elastic.co/t/deleting-old-versions/4689](https://discuss.elastic.co/t/deleting-old-versions/4689). One of the answers there said

> These 'deleted' docs will be automatically removed at some point in the  
> future when the "segments" in your index are merged. This happens in  
> the background, but can be manually triggered using the optimize API.

This is probably what I'm asking about. Say I update document 1. There is an older version now lingering in storage(soft deleted). When is this older version deleted and when is that space available to me again?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 3, 2021, 2:32am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041/4 "2021-03-03T02:32:17Z")

</div>

When a merge happens, which will depend on a few things. If you're updating somewhat regularly then the merges will occur regularly as well.

---

<div class="post-metadata">

**Author:** ![abhishekc92](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@abhishekc92](https://discuss.elastic.co/u/abhishekc92)\
**Post date:** [March 3, 2021, 2:33am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041/5 "2021-03-03T02:33:45Z")

</div>

Thanks, that helps!

---

<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:** [March 31, 2021, 2:33am UTC](https://discuss.elastic.co/t/updating-documents-immutability/266041/6 "2021-03-31T02:33:52Z")

</div>

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