# Elasticsearch will return a decreased 'hits total' value

**URL:** <https://discuss.elastic.co/t/elasticsearch-will-return-a-decreased-hits-total-value/279556>\
**Category:** Elasticsearch\
**Created:** [July 25, 2021, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-will-return-a-decreased-hits-total-value/279556 "2021-07-25T10:43:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [July 25, 2021, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-will-return-a-decreased-hits-total-value/279556/1 "2021-07-25T10:43:03Z")

</div>

Hi community  
I have a flink job which will consume Kafka message and load into Elasticsearch. In order to monitor the number of documents loaded into Elasticsearch, I write a DSL to get the 'hits total' in Elasticsearch,

```auto
GET some-indice/_search
{
   "track_total_hits":true
}

```

Another way is

```auto
GET some-indice/_count
{
}

```

Normally, this will give me an increased 'hits total' value due to stream data . However, When I execute this script frequently, I got a decreased value than previous query occasionally. Is this a normal behavior that Elasticsearch will return a decreased 'hits total' value occasionally? There is no any delete work on Elasticsearch.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 26, 2021, 7:44am UTC](https://discuss.elastic.co/t/elasticsearch-will-return-a-decreased-hits-total-value/279556/2 "2021-07-26T07:44:53Z")

</div>

Hey,

wild guess here without any further info: Is this index being constantly indexed into? If so, each of your searches will hit different shards (somtimes the primary shard, sometimes a replica). Each of those shards refreshes its data at different times, so you might end up with different counts.

Hope this helps as a start.

You can also run `POST my-index/_refresh` and then check via the `_cat/shards` API if all shards have the same amount of documents - if there is no concurrent indexing going on, otherwise the above counts again.

Also, please always specify your Elasticsearch version. Thanks!

--Alex

---

<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:** [August 23, 2021, 7:45am UTC](https://discuss.elastic.co/t/elasticsearch-will-return-a-decreased-hits-total-value/279556/3 "2021-08-23T07:45:47Z")

</div>

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