# Deleting Documents

**URL:** <https://discuss.elastic.co/t/deleting-documents/8415>\
**Category:** Elasticsearch\
**Created:** [July 13, 2012, 11:09pm UTC](https://discuss.elastic.co/t/deleting-documents/8415 "2012-07-13T23:09:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Strokin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_strokin/32/1238_2.png) [@Eugene\_Strokin](https://discuss.elastic.co/u/Eugene_Strokin)\
**Post date:** [July 13, 2012, 11:09pm UTC](https://discuss.elastic.co/t/deleting-documents/8415/1 "2012-07-13T23:09:59Z")

</div>

Hello,  
I have indexed about 1M documents. My backup ZIP file of the index was  
about 1Gb.  
After a while I needed to delete about 20% of the documents, the process  
went fine, and I don't see the deleted documents in search results.  
But the back up file still has almost the same size (actually even little  
big bigger)  
Which makes me think that the deleted documents are not actually removed  
but marked somehow as deleted.  
Am I right? And if so, is it possible to clean up somehow the index from  
the deleted documents without complete reindex. Because I expect some  
extensive rotation of the indexed documents and I need to know if I need to  
reindex documents from time to time to keep the index in reasonable size.

Thank you,  
Eugene

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 14, 2012, 11:54am UTC](https://discuss.elastic.co/t/deleting-documents/8415/2 "2012-07-14T11:54:01Z")

</div>

Hiya

> I have indexed about 1M documents. My backup ZIP file of the index was  
> about 1Gb.  
> After a while I needed to delete about 20% of the documents, the  
> process went fine, and I don't see the deleted documents in search  
> results.  
> But the back up file still has almost the same size (actually even  
> little big bigger)  
> Which makes me think that the deleted documents are not actually  
> removed but marked somehow as deleted.

Correct

> Am I right? And if so, is it possible to clean up somehow the index  
> from the deleted documents without complete reindex. Because I expect  
> some extensive rotation of the indexed documents and I need to know if  
> I need to reindex documents from time to time to keep the index in  
> reasonable size.

This will happen automatically. As you index, ES creates new 'segments'.  
These segments gradually get merged into new bigger segments (and the  
deleted docs in the old segments are removed). So you don't need to  
worry about it.

If you want to force it, you can use the 'optimize' api, but generally I  
wouldn't worry about it.

Also, depending on your data, you may want to consider other ways of  
organising your index. For instance, if you have time based data (think  
log messages), then you can have an index per day or month or whatever,  
and then just delete the old indices which are no longer required. This  
is more efficient than deleting individual docs.

clint

> Thank you,  
> Eugene

---

<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/deleting-documents/8415/3 "2017-07-06T03:20:17Z")

</div>


