Document count is lesser than the number of document indexed

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.

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

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

Can you find an example of a missing document?

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

1 Like

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