# Documents in elasticsearch getting deleted automatically?

**URL:** <https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248>\
**Category:** Elasticsearch\
**Created:** [October 28, 2016, 6:44am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248 "2016-10-28T06:44:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)\
**Post date:** [October 28, 2016, 6:44am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/1 "2016-10-28T06:44:17Z")

</div>

I'm creating an index though `logstash` and pushing data to it from a MySQL database. But what I noticed in `elasticsearch` was once the whole data is uploaded, it starts deleting some of the docs. The total number of docs is 160729. Without the scheduler it works fine.

I inserted the cron scheduler in order to check whether new rows have been added to the table. Can that be the issue?

My `logstash` conf looks like [this](http://pastebin.com/ptxjpHJ9).

Where am I going wrong? Or is this behavior common?

Any help could be appreciated.

---

<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:** [October 28, 2016, 6:52am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/2 "2016-10-28T06:52:07Z")

</div>

If you are assigning document IDs based on the data in the database and therefore end up updating documents in Elasticsearch, this will result in the old version of the document being listed as deleted.

---

<div class="post-metadata">

**Author:** ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)\
**Post date:** [October 28, 2016, 6:57am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/3 "2016-10-28T06:57:49Z")

</div>

@Christian_Dahlqvist

Yes the document\_id which I've given is the primary key (id) of the table.

So will that cause a data loss to my total docs? Or can that be ignored?

---

<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:** [October 28, 2016, 7:00am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/4 "2016-10-28T07:00:16Z")

</div>

It is how updates are reported in the stats, and is not an indication of data loss.

---

<div class="post-metadata">

**Author:** ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)\
**Post date:** [October 28, 2016, 7:01am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/5 "2016-10-28T07:01:37Z")

</div>

@Christian_Dahlqvist Oh that sounds great. 🙂

So i don't have to fear about this? Am I doin it in the right way?

Thanks.

---

<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:** [October 28, 2016, 7:09am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/6 "2016-10-28T07:09:33Z")

</div>

If records in the database are getting updated, it looks like you are catching this. Whether you are catching this correctly or not I can't tell as that depends on your data model and how you are extracting changes.

---

<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:** [October 28, 2016, 7:10am UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/7 "2016-10-28T07:10:06Z")

</div>

Have a look at [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/dynamic-indices.html#deletes-and-updates](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/dynamic-indices.html#deletes-and-updates) as well.

---

<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:08pm UTC](https://discuss.elastic.co/t/documents-in-elasticsearch-getting-deleted-automatically/64248/8 "2017-07-05T22:08:49Z")

</div>


