# Number of results per shard

**URL:** https://discuss.elastic.co/t/number-of-results-per-shard/227339
**Category:** Elasticsearch
**Created:** [April 9, 2020, 2:05pm UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339 "2020-04-09T14:05:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mredaelli](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mredaelli](https://discuss.elastic.co/u/mredaelli)
#### Post date: [April 9, 2020, 2:05pm UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339/1 "2020-04-09T14:05:39Z")

</div>

We have a basic ES instance, and I'm considering an index that has only one primary shard and one replica shard.

Doing a basic `bool` query, `hits.total` turns out to depend on which shard we hit. I get consistently different numbers specifying `?preference=_primary` or `?preference=_replica`.

The shards _are_ different in some sense, because with `_cat` I see:

```auto
index shard prirep state docs store ip node
admin_ch-v1 0 r STARTED 3220 295.2mb x.x.x.x JO8tqXw
admin_ch-v1 0 p STARTED 3220 294mb x.x.x.x aCqEzYQ

```

However, the document count is the same. I also wrote a script to get all the documents specifically from each shard (using `preference=f"_only_nodes:xxx"`) and comparing them, and, modulo a bug in my script, everything is identical.

So... what is going on?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 13, 2020, 8:02am UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339/2 "2020-04-13T08:02:24Z")

</div>

Merging of segments is not coordinated across shards, so even if primary and replica shards hold exactly the same contents their size may differ as they may have merged differently.

---

<div class="post-metadata">

### Author: ![mredaelli](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mredaelli](https://discuss.elastic.co/u/mredaelli)
#### Post date: [April 13, 2020, 3:27pm UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339/3 "2020-04-13T15:27:56Z")

</div>

That's perfectly fine. My question is why, if the contents are exactly the same, the counts for the same query are different.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 13, 2020, 3:32pm UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339/4 "2020-04-13T15:32:13Z")

</div>

Are you making changes to these indices? What is the `refesh_interval` set to?

---

<div class="post-metadata">

### Author: ![mredaelli](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mredaelli](https://discuss.elastic.co/u/mredaelli)
#### Post date: [April 15, 2020, 12:45pm UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339/5 "2020-04-15T12:45:08Z")

</div>

Sorry I didn't notice your reply earlier.

I don't see `refresh_interval` in `GET <index>/_settings`, so I assume it's the default `1s`.

And I don't think it's a matter of heavy write usage: the index receives an average of 2 new documents per day.

Also we got the same two counts, say N and M, for the same query on the two shards, trying it hours apart.

---

<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: [May 13, 2020, 12:45pm UTC](https://discuss.elastic.co/t/number-of-results-per-shard/227339/6 "2020-05-13T12:45:09Z")

</div>

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