# Total hits from \_search\_shard API and \_search API are different

**URL:** https://discuss.elastic.co/t/total-hits-from-search-shard-api-and-search-api-are-different/117698
**Category:** Elasticsearch
**Created:** [January 30, 2018, 7:45pm UTC](https://discuss.elastic.co/t/total-hits-from-search-shard-api-and-search-api-are-different/117698 "2018-01-30T19:45:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![apanimesh061](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apanimesh061/32/927_2.png) [@apanimesh061](https://discuss.elastic.co/u/apanimesh061)
#### Post date: [January 30, 2018, 7:45pm UTC](https://discuss.elastic.co/t/total-hits-from-search-shard-api-and-search-api-are-different/117698/1 "2018-01-30T19:45:16Z")

</div>

I was trying to experiment the scripts given in this [tutorial](https://hackernoon.com/parallel-scan-scroll-an-elasticsearch-index-db02583d10d1).

I am using `ES v2.3.2`.

When I execute a `matchAllQuery` with `scroll` with size `50` on the `_search` API, I get the total documents in the index and `hits` with 50 documents. I assume that if I run the same query on `_search_shard` API with the appropriate `routing` value, I should be getting the total no. of documents in a specific shard and 50 `hits` in that shard?

I have a small index that has 2276 documents. I have a total of 16 shards, so executing the `matchAllQuery` query with the `_search_shard` API for each shard I get:

```
Shard Total Matches
1 160
2 137
3 137
4 142
5 137
6 134
7 134
8 149
9 140
10 142
11 134
12 137
13 115
14 156
15 140
16 125

```

which sums to `2219` documents. I was expecting this to be `2276` instead. I there any concept that I have misunderstood?

Another thing is that all of the responses have a field `terminated_early: true`. Could this be an issue here?

---

<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: [February 27, 2018, 7:45pm UTC](https://discuss.elastic.co/t/total-hits-from-search-shard-api-and-search-api-are-different/117698/2 "2018-02-27T19:45:30Z")

</div>

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