# Document count is lesser than the number of document indexed

**URL:** <https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686>\
**Category:** Elasticsearch\
**Created:** [December 20, 2018, 11:31am UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686 "2018-12-20T11:31:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msmani](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@msmani](https://discuss.elastic.co/u/msmani)\
**Post date:** [December 20, 2018, 11:31am UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686/1 "2018-12-20T11:31:38Z")

</div>

I am indexing via bulk api (provided by `org.elasticsearch.client.RestHighLevelClient` ), the number of document I index is **381942** but when I use the \_count api of elasticsearch it shows lesser count, that number varies each time I index but it is always less (e.g. **238632, 279241, 282325** etc). When I try to refresh then the count increases by 1. What's going on?

Note: I have checked the response and **there are no failures** , as well.

> <https://stackoverflow.com/questions/53865728/elasticsearch-document-count-is-lesser-than-the-number-of-document-indexed>

---

<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:** [December 20, 2018, 12:30pm UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686/2 "2018-12-20T12:30:33Z")

</div>

May be you are using sometimes the same id and one request overwrites an existing document?

---

<div class="post-metadata">

**Author:** ![msmani](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@msmani](https://discuss.elastic.co/u/msmani)\
**Post date:** [December 20, 2018, 12:37pm UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686/3 "2018-12-20T12:37:58Z")

</div>

Nope, all the ids are unique. Kindly go through the comment section in the stackoverflow link where I have already answered all these kind of queries

---

<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:** [December 21, 2018, 12:54pm UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686/4 "2018-12-21T12:54:16Z")

</div>

Can you find an example of a missing document?

---

<div class="post-metadata">

**Author:** ![msmani](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@msmani](https://discuss.elastic.co/u/msmani)\
**Post date:** [December 21, 2018, 1:14pm UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686/5 "2018-12-21T13:14:12Z")

</div>

my bad, It is not elasticsearch problem, I didn't add order by in my query, so as per Postgres the order won't be consistent. Once I added the order by class it is working fine

---

<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:** [January 18, 2019, 1:14pm UTC](https://discuss.elastic.co/t/document-count-is-lesser-than-the-number-of-document-indexed/161686/6 "2019-01-18T13:14:14Z")

</div>

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