# How to Delete (Hard Delete) document from Elasticsearch Disk?

**URL:** https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351
**Category:** Elasticsearch
**Created:** [November 27, 2018, 1:45pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351 "2018-11-27T13:45:37Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![HARSHAL\_CHAUDHARI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshal_chaudhari/32/36058_2.png) [@HARSHAL\_CHAUDHARI](https://discuss.elastic.co/u/HARSHAL_CHAUDHARI)
#### Post date: [November 27, 2018, 1:45pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/1 "2018-11-27T13:45:37Z")

</div>

Hi,

I am trying to delete a document from elastic search (using .Net NEST library), but a document is not deleted from a segment, just marked as deleted. (does not free the disk space.)

Could you please let us know **how to delete a document** from elastic search **disk** and in other words **how to free the disk space**.

Thanks in advance.

Regards  
Harshal

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 27, 2018, 1:51pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/2 "2018-11-27T13:51:18Z")

</div>

Perform the delete and then run a [force merge](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/indices-forcemerge.html) with `max_num_segments` set to 1 or the `only_expunge_deletes` parameter. Be aware that this is an expensive operation in terms of processing and disk I/O.

---

<div class="post-metadata">

### Author: ![HARSHAL\_CHAUDHARI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshal_chaudhari/32/36058_2.png) [@HARSHAL\_CHAUDHARI](https://discuss.elastic.co/u/HARSHAL_CHAUDHARI)
#### Post date: [November 27, 2018, 2:15pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/3 "2018-11-27T14:15:27Z")

</div>

I have deleted the existing all index and document and now i want to free the space from Elastic search, Please let me know how i can.

Thank you!, I will try above fix.

---

<div class="post-metadata">

### Author: ![HARSHAL\_CHAUDHARI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshal_chaudhari/32/36058_2.png) [@HARSHAL\_CHAUDHARI](https://discuss.elastic.co/u/HARSHAL_CHAUDHARI)
#### Post date: [November 28, 2018, 3:45pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/4 "2018-11-28T15:45:03Z")

</div>

> [@HARSHAL\_CHAUDHARI](#):
>
> I have deleted the existing all index and document and now i want to free the space from Elastic search, Please let me know how i can.

Could you please help us here, i have tried below

POST /kimchy/\_forcemerge?only\_expunge\_deletes=false&max\_num\_segments=100&flush=true

but no luck.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 28, 2018, 3:49pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/5 "2018-11-28T15:49:39Z")

</div>

That is not what I recommended. Try `POST /indexname/_forcemerge?max_num_segments=1&flush=true` or `POST /indexname/_forcemerge?only_expunge_deletes=true`.

Be aware it is an expensive operation and can take some time to run.

---

<div class="post-metadata">

### Author: ![HARSHAL\_CHAUDHARI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshal_chaudhari/32/36058_2.png) [@HARSHAL\_CHAUDHARI](https://discuss.elastic.co/u/HARSHAL_CHAUDHARI)
#### Post date: [November 28, 2018, 3:53pm UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/6 "2018-11-28T15:53:28Z")

</div>

Thanks for quick response, let me try,

If i have already deleted the index in that case what I will do.

---

<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: [November 29, 2018, 1:49am UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/7 "2018-11-29T01:49:40Z")

</div>

> [@HARSHAL\_CHAUDHARI](#):
>
> If i have already deleted the index in that case what I will do.

if you have deleted the index, you will not be able to run a force merge on i.

---

<div class="post-metadata">

### Author: ![HARSHAL\_CHAUDHARI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshal_chaudhari/32/36058_2.png) [@HARSHAL\_CHAUDHARI](https://discuss.elastic.co/u/HARSHAL_CHAUDHARI)
#### Post date: [November 30, 2018, 5:35am UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/8 "2018-11-30T05:35:58Z")

</div>

Could you please let me know so how i can free the disk space for same.

Thanks again for response.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 30, 2018, 5:39am UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/9 "2018-11-30T05:39:46Z")

</div>

If you have deleted the index the disk space has been freed, hasn’t it? I am not sure I understand the question.

---

<div class="post-metadata">

### Author: ![HARSHAL\_CHAUDHARI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshal_chaudhari/32/36058_2.png) [@HARSHAL\_CHAUDHARI](https://discuss.elastic.co/u/HARSHAL_CHAUDHARI)
#### Post date: [November 30, 2018, 6:37am UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/10 "2018-11-30T06:37:16Z")

</div>

Hi Christian,

I am using Cerebro tool (Please see below screen 1)  
Note: In below screen there is no any index exist, still showing the disk utilization.

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/2/4/2439f7da76dee43c99857a7439c56e9f278c3e51.png)

For reference (Screen 2)

 ![Capture_1](https://us1.discourse-cdn.com/elastic/original/3X/7/2/72e42852752d5aa91b242b5dd1dd1b3413c03fc6.png)

Please guide me how i can free up the disk space.

Thank You!

Regards  
Harshal Chaudhari

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 30, 2018, 6:38am UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/11 "2018-11-30T06:38:55Z")

</div>

When Elasticsearch deletes an index the data files are removed. If you log into the box, what is taking up space? How large was the index you deleted?

---

<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: [December 28, 2018, 6:38am UTC](https://discuss.elastic.co/t/how-to-delete-hard-delete-document-from-elasticsearch-disk/158351/12 "2018-12-28T06:38:59Z")

</div>

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