# Total hits showing up as 0, but documents exist. 6.3 Rest high level client, 7.1 cluster

**URL:** <https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006>\
**Category:** Elasticsearch\
**Tags:** language-clients, migration, snapshot-and-restore\
**Created:** [June 27, 2023, 2:40pm UTC](https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006 "2023-06-27T14:40:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hi\_Jonk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hi_jonk/32/105695_2.png) [@Hi\_Jonk](https://discuss.elastic.co/u/Hi_Jonk)\
**Post date:** [June 27, 2023, 2:40pm UTC](https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006/1 "2023-06-27T14:40:13Z")

</div>

Hi, I had a cluster that was running on ES v6.7 with a REST high level client v6.3. We want to upgrade, so as per this suggestion: [Clarify high level REST client compatibility between 6 and 7](https://discuss.elastic.co/t/clarify-high-level-rest-client-compatibility-between-6-and-7/241973)

- created a test cluster at 6.7,
- migrated the data to the test cluster,
- upgraded my test cluster to v7.10,
- and kept the client at 6.3.

Upon calling the search API, the results are correct, however, the hit count is showing up at 0.

```auto
{
"took": 37,
"timed_out": false,
"_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
},
"hits": {
    "total": 0,
    "max_score": 2.0,
    "hits": [{
        "_index": "indexName",
        "_type": "doc",
        "_id": "identifier",
        "_score": 2.0,
        "_source": {
             <actual data>
                  .
                  .

```

How can I fix this?

---

<div class="post-metadata">

**Author:** ![eMitch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emitch/32/93607_2.png) [@eMitch](https://discuss.elastic.co/u/eMitch)\
**Post date:** [June 27, 2023, 6:47pm UTC](https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006/2 "2023-06-27T18:47:26Z")

</div>

Have you verified that performing this search via Dev Tools yields the proper `hits` count?  
Is there a reason you're leaving the client on 6.3 instead of moving to 7x?

Even though it may work, it's still recommended to keep the client on the same version as the stack.  
Also, you may want to consider going to the latest release in 7.17.x as 7.10 is EOL.

---

<div class="post-metadata">

**Author:** ![Hi\_Jonk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hi_jonk/32/105695_2.png) [@Hi\_Jonk](https://discuss.elastic.co/u/Hi_Jonk)\
**Post date:** [June 28, 2023, 4:55am UTC](https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006/3 "2023-06-28T04:55:09Z")

</div>

I am eventually planning to bump the client up as well. If it was forwards compatible, it would make for a smooth rolling upgrade such that I wouldn't have to coordinate between upgrading the cluster version and updating code to use the new client

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [June 28, 2023, 7:29am UTC](https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006/4 "2023-06-28T07:29:55Z")

</div>

This is explained in the breaking change section: [Breaking changes in 7.0 | Elasticsearch Guide [7.0] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#hits-total-omitted-if-disabled)

Hit count has a more precise format in 7.x, and you have to add the `track_total_hits` query parameter to ask the server to return the 6.x count format.

---

<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:** [July 26, 2023, 7:30am UTC](https://discuss.elastic.co/t/total-hits-showing-up-as-0-but-documents-exist-6-3-rest-high-level-client-7-1-cluster/337006/5 "2023-07-26T07:30:01Z")

</div>

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