# Delete Document from Index

**URL:** <https://discuss.elastic.co/t/delete-document-from-index/8422>\
**Category:** Elasticsearch\
**Created:** [July 16, 2012, 1:38pm UTC](https://discuss.elastic.co/t/delete-document-from-index/8422 "2012-07-16T13:38:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [July 16, 2012, 1:38pm UTC](https://discuss.elastic.co/t/delete-document-from-index/8422/1 "2012-07-16T13:38:55Z")

</div>

Hi

I ran delete query on index documents. It reduces the document count from  
57309066 to 6167240

But it is very strange my index size 128 GB remains the same. Can anybody  
explain this unexpected behavior?

How can reduce index size with deleted documents?

Regards,  
Pulkit

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 16, 2012, 6:24pm UTC](https://discuss.elastic.co/t/delete-document-from-index/8422/2 "2012-07-16T18:24:16Z")

</div>

Lucene doesn't remove deleted documents from the index files right away.  
Instead, it marks them as deleted and gets rid of them eventually during  
segment merges. You can force this process by running:

curl -XPOST  
'[http://localhost:9200/your-index/\_optimize?only\_expunge\_deletes=true](http://localhost:9200/your-index/_optimize?only_expunge_deletes=true)'

See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.html)  
for more information.

On Monday, July 16, 2012 9:38:55 AM UTC-4, kartavya wrote:

> Hi
> 
> I ran delete query on index documents. It reduces the document count from  
> 57309066 to 6167240
> 
> But it is very strange my index size 128 GB remains the same. Can anybody  
> explain this unexpected behavior?
> 
> How can reduce index size with deleted documents?
> 
> Regards,  
> Pulkit

---

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [July 17, 2012, 9:12am UTC](https://discuss.elastic.co/t/delete-document-from-index/8422/3 "2012-07-17T09:12:01Z")

</div>

Thanks.  
It helps.

On Mon, Jul 16, 2012 at 11:54 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> Lucene doesn't remove deleted documents from the index files right away.  
> Instead, it marks them as deleted and gets rid of them eventually during  
> segment merges. You can force this process by running:
> 
> curl -XPOST '  
> [http://localhost:9200/your-index/\_optimize?only\_expunge\_deletes=true](http://localhost:9200/your-index/_optimize?only_expunge_deletes=true)'
> 
> See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.htmlfor) more information.
> 
> On Monday, July 16, 2012 9:38:55 AM UTC-4, kartavya wrote:
> 
> > Hi
> > 
> > I ran delete query on index documents. It reduces the document count from  
> > 57309066 to 6167240
> > 
> > But it is very strange my index size 128 GB remains the same. Can anybody  
> > explain this unexpected behavior?
> > 
> > How can reduce index size with deleted documents?
> > 
> > Regards,  
> > Pulkit

---

<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, 3:20am UTC](https://discuss.elastic.co/t/delete-document-from-index/8422/4 "2017-07-06T03:20:10Z")

</div>


