# Elasticsearch:Release disk space automatic or call the api?

**URL:** https://discuss.elastic.co/t/elasticsearch-release-disk-space-automatic-or-call-the-api/53773
**Category:** Elasticsearch
**Created:** [June 23, 2016, 11:42am UTC](https://discuss.elastic.co/t/elasticsearch-release-disk-space-automatic-or-call-the-api/53773 "2016-06-23T11:42:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![famoss](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@famoss](https://discuss.elastic.co/u/famoss)
#### Post date: [June 23, 2016, 11:42am UTC](https://discuss.elastic.co/t/elasticsearch-release-disk-space-automatic-or-call-the-api/53773/1 "2016-06-23T11:42:24Z")

</div>

The official document says:  
`As already mentioned in Updating a Whole Document, deleting a document doesn’t immediately remove the document from disk; it just marks it as deleted. Elasticsearch will clean up deleted documents in the background as you continue to index more data.` and there is a merge scheduler task to merge data.

[after delete doc](http://stackoverflow.com/questions/20608417/elasticsearch-how-to-free-store-size-after-deleting-documents) says `Deleting documents only flags these as deleted, so they would not be searched. To reclaim disk space, you have to optimize the index`

But,i find when i `delete` a `document`,the disk space will not be released until i use `force merge` api. Why?

If so,if i use `delete-by-query` plugin,i will need to use `force merge api` every time?

My `elasticsearch's` version is `2.3.1`.

---

<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: [June 23, 2016, 12:40pm UTC](https://discuss.elastic.co/t/elasticsearch-release-disk-space-automatic-or-call-the-api/53773/2 "2016-06-23T12:40:22Z")

</div>

> [@famoss](#):
>
> optimize

That is the old name for the force merge api.

The real answer is that the only efficient delete in Elasticsearch is deleting a whole index. If efficient deletes are a thing you need then you need to design your index strategy so you can delete a whole index when you want to delete stuff.

You _can_ use the force merge API to reclaim space after a big delete-by-query but it is very inefficient.

---

<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:41pm UTC](https://discuss.elastic.co/t/elasticsearch-release-disk-space-automatic-or-call-the-api/53773/3 "2017-07-05T22:41:06Z")

</div>


