# Deleted docs

**URL:** <https://discuss.elastic.co/t/deleted-docs/2927>\
**Category:** Elasticsearch\
**Created:** [April 23, 2010, 3:11pm UTC](https://discuss.elastic.co/t/deleted-docs/2927 "2010-04-23T15:11:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![megAmin](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@megAmin](https://discuss.elastic.co/u/megAmin)\
**Post date:** [April 23, 2010, 3:11pm UTC](https://discuss.elastic.co/t/deleted-docs/2927/1 "2010-04-23T15:11:29Z")

</div>

wenever i update by re-indexing the previous docs are marked as deleted docs. how to delete those docs?

---

<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:** [April 23, 2010, 3:44pm UTC](https://discuss.elastic.co/t/deleted-docs/2927/2 "2010-04-23T15:44:00Z")

</div>

Thats how Lucene works. Deleted docs are just marked as deleted, and  
eventually gets expunged when internal index segments gets merged. This can  
be explicitly invoked using the optimized API:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/admin/indices/optimize/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/optimize/).  
Note the special flag of only\_expunge\_deletes which only optimizes segments  
that have deletes.

As a side note, optimize is a heavy operation. If you end up deleting a  
large potion of your index when you reindex, you might as well create a new  
index under a different name, do then reindexing into it, and then delete  
the old index. You can use index aliases to do this seamlessly (  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/admin/indices/aliases/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/aliases/))  
from other searches. Not sure if this is what you are trying to do, but  
might help.

cheers,  
shay.banon

On Fri, Apr 23, 2010 at 6:11 PM, megAmin [amin.megha@gmail.com](mailto:amin.megha@gmail.com) wrote:

> ## wenever i update by re-indexing the previous docs are marked as deleted docs. how to delete those docs?
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Deleted-docs-tp745958p745958.html](http://elasticsearch-users.115913.n3.nabble.com/Deleted-docs-tp745958p745958.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:24am UTC](https://discuss.elastic.co/t/deleted-docs/2927/3 "2017-07-06T04:24:24Z")

</div>


