# When does ES free up disk space?

**URL:** <https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000>\
**Category:** Elasticsearch\
**Created:** [March 1, 2011, 7:28am UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000 "2011-03-01T07:28:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Petri\_Lehtinen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petri_lehtinen/32/3145_2.png) [@Petri\_Lehtinen](https://discuss.elastic.co/u/Petri_Lehtinen)\
**Post date:** [March 1, 2011, 7:28am UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000/1 "2011-03-01T07:28:55Z")

</div>

Hi!

I have a single node with zero configuration (the default). It takes  
about 20GB of disk space and had 45M documents. I removed  
approximately half of the documents, but no disk space was freed. I  
also ran the "optimize" command by hand, but still no free space.

So, when is the disk space going to be freed up? Or is it? I'm using  
version 0.11.0.

Petri Lehtinen

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 1, 2011, 7:05pm UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000/2 "2011-03-01T19:05:38Z")

</div>

When you delete a doc, it does not get actually deleted until the relevant internal lucene segment (a subset of the actual lucene index) that includes deletes gets merged "out". If you want to completely optimize an index, you can optimize it down into a single segment, or run the the optimize request with only\_expunge\_deletes set to true. Note, this will be an intensive IO operation.  
On Tuesday, March 1, 2011 at 9:28 AM, Petri Lehtinen wrote:

> Hi!
> 
> I have a single node with zero configuration (the default). It takes  
> about 20GB of disk space and had 45M documents. I removed  
> approximately half of the documents, but no disk space was freed. I  
> also ran the "optimize" command by hand, but still no free space.
> 
> So, when is the disk space going to be freed up? Or is it? I'm using  
> version 0.11.0.
> 
> Petri Lehtinen

---

<div class="post-metadata">

**Author:** ![Petri\_Lehtinen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petri_lehtinen/32/3145_2.png) [@Petri\_Lehtinen](https://discuss.elastic.co/u/Petri_Lehtinen)\
**Post date:** [March 2, 2011, 6:55am UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000/3 "2011-03-02T06:55:53Z")

</div>

On Mar 1, 9:05 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> When you delete a doc, it does not get actually deleted until the relevant internal lucene segment (a subset of the actual lucene index) that includes deletes gets merged "out". If you want to completely optimize an index, you can optimize it down into a single segment, or run the the optimize request with only\_expunge\_deletes set to true. Note, this will be an intensive IO operation.

This is what I did:

curl -XPOST '[http://localhost:9200/\_optimize](http://localhost:9200/_optimize)' -d  
'{"only\_expunge\_deletes": true}'

It took a long time to complete, but as said before, no disk space was  
freed.

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 2, 2011, 8:02am UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000/4 "2011-03-02T08:02:24Z")

</div>

Hi Petri,

I did not use it myself yet but based on the docs  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.html) I  
would say that the parameter is expected to be used as a URL parameter:

curl -XPOST 'localhost:9200/\_optimize?only\_expunge\_deletes=true'

Regards,  
Lukas

On Wed, Mar 2, 2011 at 7:55 AM, Petri Lehtinen [petri@digip.org](mailto:petri@digip.org) wrote:

> On Mar 1, 9:05 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > When you delete a doc, it does not get actually deleted until the  
> > relevant internal lucene segment (a subset of the actual lucene index) that  
> > includes deletes gets merged "out". If you want to completely optimize an  
> > index, you can optimize it down into a single segment, or run the the  
> > optimize request with only\_expunge\_deletes set to true. Note, this will be  
> > an intensive IO operation.
> 
> This is what I did:
> 
> curl -XPOST '[http://localhost:9200/\_optimize](http://localhost:9200/_optimize)' -d  
> '{"only\_expunge\_deletes": true}'
> 
> It took a long time to complete, but as said before, no disk space was  
> freed.

---

<div class="post-metadata">

**Author:** ![Petri\_Lehtinen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petri_lehtinen/32/3145_2.png) [@Petri\_Lehtinen](https://discuss.elastic.co/u/Petri_Lehtinen)\
**Post date:** [March 2, 2011, 9:34am UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000/5 "2011-03-02T09:34:14Z")

</div>

On Mar 2, 10:02 am, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> I did not use it myself yet but based on the docshttp://www.elasticsearch.org/guide/reference/api/admin-indices-optimi...I  
> would say that the parameter is expected to be used as a URL parameter:
> 
> curl -XPOST 'localhost:9200/\_optimize?only\_expunge\_deletes=true'

Wow, this worked. Thanks a lot!

---

<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, 4:11am UTC](https://discuss.elastic.co/t/when-does-es-free-up-disk-space/4000/6 "2017-07-06T04:11:02Z")

</div>


