### Elasticsearch Version

8.4.1

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

macOs 10.15.7, Elasticsearch running in docker container

### Problem Description

I index 5 documents containing a minmal set of fields. One field is named `name` and for one of the docs it is empty (`""`) and for one it does not exist.

I then search for documents where this field exists. The returned hits a alright, but the value value in the total relation object is wrong. This worked in 8.3.3, but erros in 8.4.1

Expected behaviour: the total hit value is 4

Actual behaviour: the value of 3 is returned


### Steps to Reproduce

Post the following documents to `testindex`:

```
{
	"name": "name-1",
}

{
	"name": "name-2",
}

{
	"name": "name-3",
}

{
	"name": "",
}

{
	value: 42
}
```

send the following query:
```
POST /testindex/_search 
{
  "query": {
    "exists": {
      "field": "name"
    }
  }
}
```

This returns:
```
{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 1,
    "total": 1
  },
  "hits": {
    "hits": [
      {
        "_id": "4T0z9YIBgYaqNSSuHK8i",
        "_index": "testindex",
        "_score": 1.0,
        "_source": {
          "name": "name-1"
        }
      },
      {
        "_id": "4j0z9YIBgYaqNSSuOK80",
        "_index": "testindex",
        "_score": 1.0,
        "_source": {
          "name": "name-2"
        }
      },
      {
        "_id": "4z0z9YIBgYaqNSSuSq8F",
        "_index": "testindex",
        "_score": 1.0,
        "_source": {
          "name": "name-3"
        }
      },
      {
        "_id": "5D0z9YIBgYaqNSSuX68P",
        "_index": "testindex",
        "_score": 1.0,
        "_source": {
          "name": ""
        }
      }
    ],
    "max_score": 1.0,
    "total": {
      "relation": "eq",
      "value": 3
    }
  },
  "timed_out": false,
  "took": 62
}

```

Although 4 documents are returned, the total value returned is 3.

This is a problem for me as I use queries with a size of 0 and track_total_hits set to true to do a count query. This now returns wrong results.

### Logs (if relevant)

_No response_
server/src/main/java/org/elasticsearch/search/query/TopDocsCollectorContext.java
}
            if (numberOfShards == 1) {
                
                if (topDocs.topDocs.scoreDocs.length > 0) {
                    
                    scrollContext.lastEmittedDoc = topDocs.topDocs.scoreDocs[topDocs.topDocs.scoreDocs.length - 1];
                }
            }
            result.topDocs(topDocs, sortAndFormats == null ? null : sortAndFormats.formats);
        }
    }
    /**
     * Returns query total hit count if the <code>query</code> is a {@link MatchAllDocsQuery}
     * or a {@link TermQuery} and the <code>reader</code> has no deletions,
     * -1 otherwise.
     */
    static int shortcutTotalHitCount(IndexReader reader, Query query) throws IOException {
        while (true) {
            
            
            
            
            if (query instanceof ConstantScoreQuery) {
                query = ((ConstantScoreQuery) query).getQuery();
            } else if (query instanceof BoostQuery) {
                query = ((BoostQuery) query).getQuery();
            } else {
                break;
            }
        }