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

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

  • 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.

{
"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?

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.

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

This is explained in the breaking change section: Breaking changes in 7.0 | Elasticsearch Guide [7.0] | Elastic

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.

1 Like

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