# Indice documents count goes up after update

**URL:** <https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325>\
**Category:** Elasticsearch\
**Created:** [February 27, 2020, 8:31pm UTC](https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325 "2020-02-27T20:31:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goran](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@Goran](https://discuss.elastic.co/u/Goran)\
**Post date:** [February 27, 2020, 8:31pm UTC](https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325/1 "2020-02-27T20:31:35Z")

</div>

After documents update, documents count is doubled but I still have the same number of docs when I query indice. Deleted docs show the number before update and that's expected, but I didn't expects documents count to be higher. What can be a reason?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 28, 2020, 1:13am UTC](https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325/2 "2020-02-28T01:13:02Z")

</div>

Welcome!

It's probably because updating a document is behind the scene a DELETE + and INDEX operation.

---

<div class="post-metadata">

**Author:** ![Goran](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@Goran](https://discuss.elastic.co/u/Goran)\
**Post date:** [February 29, 2020, 2:14pm UTC](https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325/3 "2020-02-29T14:14:16Z")

</div>

Thank you. Does this mean that I should increase the number of shards if I have more updates prepared for the future? To be concrete, I have 1.5 million docs. After update "documents count" is 3 mil. and I have 1.5 mil. deleted. When I query the indice, I still have 1.5 mil. docs. So if I perform 2 more updates, does it mean that I will have 6 mil documents count and 4.5 million deleted?

If that's the case then I should reindex or copy the data to indice with more shards. Am I right?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 29, 2020, 5:22pm UTC](https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325/4 "2020-02-29T17:22:43Z")

</div>

No. Merge is happening behind the scene so it will be eventually purged.  
Note that if you are updating the whole dataset everytime it's better to index in a new index and delete the old one.  
With alias on top of it.

---

<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:** [March 28, 2020, 5:22pm UTC](https://discuss.elastic.co/t/indice-documents-count-goes-up-after-update/221325/5 "2020-03-28T17:22:54Z")

</div>

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