# Query sometimes result smaller than it should be

**URL:** <https://discuss.elastic.co/t/query-sometimes-result-smaller-than-it-should-be/209943>\
**Category:** Elasticsearch\
**Created:** [November 29, 2019, 9:09am UTC](https://discuss.elastic.co/t/query-sometimes-result-smaller-than-it-should-be/209943 "2019-11-29T09:09:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wnishi-swd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wnishi-swd/32/58523_2.png) [@wnishi-swd](https://discuss.elastic.co/u/wnishi-swd)\
**Post date:** [November 29, 2019, 9:09am UTC](https://discuss.elastic.co/t/query-sometimes-result-smaller-than-it-should-be/209943/1 "2019-11-29T09:09:10Z")

</div>

Hi, I'm a beginner of Elasticsearch and trying to count documents in an index.  
But I faced a situation that does not fit my intuition.

- I'm using Elasticsearch 6.4.
- my elasticsearch index has 10 documents.
- every document has the form `{"type":"foo", "variableProp":1}`.
  - where "type" is one of "foo" "bar" "baz", and "variableProp" varies.

- my process updates "variableProp" in these documents every second.
  - using Bulk API specifying 'index' actions.
  - it does not change the "type".

- another process queries the index every 5 seconds.
  - aggregating by "type" term and count each type of document.

I expect the query produces the same result every time and the sum of each counts to be 10, but sometimes it results 9 or 8 or more smaller.  
It seems they will not be larger than it should be, but can be smaller.

Can anyone explain this situation?  
Is there a way to avoid the decreasing counts?

---

<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:** [December 27, 2019, 9:09am UTC](https://discuss.elastic.co/t/query-sometimes-result-smaller-than-it-should-be/209943/2 "2019-12-27T09:09:14Z")

</div>

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