# Inconsistent doc count

**URL:** <https://discuss.elastic.co/t/inconsistent-doc-count/146589>\
**Category:** Elasticsearch\
**Created:** [August 29, 2018, 11:06pm UTC](https://discuss.elastic.co/t/inconsistent-doc-count/146589 "2018-08-29T23:06:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashokm](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@ashokm](https://discuss.elastic.co/u/ashokm)\
**Post date:** [August 29, 2018, 11:06pm UTC](https://discuss.elastic.co/t/inconsistent-doc-count/146589/1 "2018-08-29T23:06:48Z")

</div>

We have a 6 node elasticsearch 2.4.4 cluster. Each index has 2 shards and 1 replica. When we call \_search?size=10, "total" keeps alternating between 257566/257707 in an index. Expected total count is 257707. When i query \_search?size=10&preference=\_primary, I get 257707 and when i query \_search?size=10&preference=\_replica I get 257566.

We are noticing this only when we use delete by query to delete some documents and do indexing again. Below is the call we are making to delete the docs

`DeleteByQueryRequestBuilder(client, DeleteByQueryAction.INSTANCE) .setIndices(indexName) .setTypes(mappingName) .setSource(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()).size(5000).toString()) .execute() .actionGet()`

Any theory on why we are getting inconsistent count is really appreciated

---

<div class="post-metadata">

**Author:** ![ashokm](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@ashokm](https://discuss.elastic.co/u/ashokm)\
**Post date:** [August 30, 2018, 4:17pm UTC](https://discuss.elastic.co/t/inconsistent-doc-count/146589/2 "2018-08-30T16:17:43Z")

</div>

Any insights is really appreciated. Is the delete by query operation the way we are doing, is it synchronous and deletes the data from replicas immediately?

---

<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:** [September 27, 2018, 4:32pm UTC](https://discuss.elastic.co/t/inconsistent-doc-count/146589/3 "2018-09-27T16:32:11Z")

</div>

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