# Unable to free disk space after deleting some documents

**URL:** <https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325>\
**Category:** Elasticsearch\
**Created:** [April 13, 2016, 11:21pm UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325 "2016-04-13T23:21:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep\_Gowda](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@Pradeep\_Gowda](https://discuss.elastic.co/u/Pradeep_Gowda)\
**Post date:** [April 13, 2016, 11:21pm UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/1 "2016-04-13T23:21:33Z")

</div>

Hey All,  
I deleted few documents using Java API using bulk API. The response was a success and when I check the disk space, I did not see any change.

Later I used force merge to optimize the index as shown below

```
 ForceMergeResponse forceMergeResponse = client.admin().indices()
                .forceMerge(new ForceMergeRequest(indexName).onlyExpungeDeletes(true).maxNumSegments(1).flush(true)).actionGet();

```

But still elastic did not free the space.

I tried to trigger optimize request as well but no success.

`curl -XPOST 'localhost:9200/indexName/_optimize?only_expunge_deletes=true'`

Can someone please help me with this?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 14, 2016, 1:07am UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/2 "2016-04-14T01:07:47Z")

</div>

Depending on how many you deleted it could still be running. You can check  
it with the cat merges API. In general the best way to free up space is to  
remove whole indexes. This is why people use daily or weekly indexes. Well,  
there are other reasons too, but this is a good reason.

The API call you made will make one large segment which will cause you  
trouble down the line if you make updates to documents in that segment  
because it will rarely be selected for merging. Generally you shouldn't use  
the optimize API unless you are done writing to the index.

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [April 14, 2016, 1:28am UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/3 "2016-04-14T01:28:21Z")

</div>

I find this interesting topic from the system resource point of view.  
Looks like adding the datetime to file name is very important.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Gowda](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@Pradeep\_Gowda](https://discuss.elastic.co/u/Pradeep_Gowda)\
**Post date:** [April 14, 2016, 1:42am UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/4 "2016-04-14T01:42:40Z")

</div>

@nik9000 The problem with my design is, I have fixed number of index and each index has multiple index type. Also each index has some restriction and each can grow up to some size; let's say 1GB. Periodically I check the size if it is greater than GB knock off the data from oldest index type and recheck the size again. Even after removing all the documents from index type size doesn't change.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 14, 2016, 1:56am UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/5 "2016-04-14T01:56:42Z")

</div>

Right. It is much more efficient to nuke whole indexes to free up space. So if possible, you should think about reworking your stuff to use indexes for time periods rather than types per time period.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Gowda](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@Pradeep\_Gowda](https://discuss.elastic.co/u/Pradeep_Gowda)\
**Post date:** [April 14, 2016, 2:00am UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/6 "2016-04-14T02:00:01Z")

</div>

@nik9000, Sure. Will work on that. But is there any temporary fix for my issue 😃

---

<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:59pm UTC](https://discuss.elastic.co/t/unable-to-free-disk-space-after-deleting-some-documents/47325/7 "2017-07-05T22:59:26Z")

</div>


