# Number of docs differents between primary shards and replicas

**URL:** <https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228>\
**Category:** Elasticsearch\
**Created:** [February 23, 2017, 1:42pm UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228 "2017-02-23T13:42:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericpietro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpietro/32/9685_2.png) [@ericpietro](https://discuss.elastic.co/u/ericpietro)\
**Post date:** [February 23, 2017, 1:42pm UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/1 "2017-02-23T13:42:40Z")

</div>

hi everybody,  
i have a 3 nodes 2.3.3 elk cluster.  
i have one index named "idx\_mys\_pmm\_iis-2017.02". 5 primary shards, 5 replicas shards.  
Logstash 2.3.3 push the logs in this index.  
in sense, i do :  
"GET \_cat/shards/idx\_mys\_pmm\_iis-2017.02?v"

and i see this in response :  
index shard prirep state docs store ip node  
idx\_mys\_pmm\_iis-2017.02 4 p STARTED 1809576 1.5gb node\_UD0TX039  
idx\_mys\_pmm\_iis-2017.02 4 r STARTED 1809314 1.5gb node\_UD0TX037  
idx\_mys\_pmm\_iis-2017.02 3 r STARTED 1808801 1.5gb node\_UD0TX038  
idx\_mys\_pmm\_iis-2017.02 3 p STARTED 1808801 1.5gb node\_UD0TX037  
idx\_mys\_pmm\_iis-2017.02 1 p STARTED 1811286 1.6gb node\_UD0TX039  
idx\_mys\_pmm\_iis-2017.02 1 r STARTED 1811286 1.5gb node\_UD0TX037  
idx\_mys\_pmm\_iis-2017.02 2 r STARTED 1808775 1.5gb node\_UD0TX039  
idx\_mys\_pmm\_iis-2017.02 2 p STARTED 1808775 1.5gb node\_UD0TX038  
idx\_mys\_pmm\_iis-2017.02 0 r STARTED 1809785 1.5gb node\_UD0TX038  
idx\_mys\_pmm\_iis-2017.02 0 p STARTED 1809848 1.5gb node\_UD0TX037

as u can see, it exists differences between primary and replicas shards for #0 and #4 shards.  
then , I do a refresh on this index :  
POST /idx\_mys\_pmm\_iis-2017.02/\_refresh

and this is what i get :  
index shard prirep state docs store ip node  
idx\_mys\_pmm\_iis-2017.02 4 p STARTED 1811052 1.5gb node\_UD0TX039  
idx\_mys\_pmm\_iis-2017.02 4 r STARTED 1811052 1.6gb node\_UD0TX037  
idx\_mys\_pmm\_iis-2017.02 3 r STARTED 1810761 1.5gb node\_UD0TX038  
idx\_mys\_pmm\_iis-2017.02 3 p STARTED 1810761 1.5gb node\_UD0TX037  
idx\_mys\_pmm\_iis-2017.02 1 p STARTED 1813351 1.6gb node\_UD0TX039  
idx\_mys\_pmm\_iis-2017.02 1 r STARTED 1813351 1.5gb node\_UD0TX037  
idx\_mys\_pmm\_iis-2017.02 2 r STARTED 1810846 1.5gb node\_UD0TX039  
idx\_mys\_pmm\_iis-2017.02 2 p STARTED 1810846 1.5gb node\_UD0TX038  
idx\_mys\_pmm\_iis-2017.02 0 r STARTED 1811591 1.5gb node\_UD0TX038  
idx\_mys\_pmm\_iis-2017.02 0 p STARTED 1811591 1.5gb node\_UD0TX037

all is correct now...

can u explain to me why some events are in a primary shard and not in the replica's one (or vice versa) ?  
and why, when i do a refresh, all become correct ... til the next refresh ...

ty very much for your answer...

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [February 23, 2017, 10:19pm UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/2 "2017-02-23T22:19:37Z")

</div>

The default for refresh should be 1s unless edited. What is your setting output for your index?

GET /idx\_mys\_pmm\_iis-2017.02/\_settings

---

<div class="post-metadata">

**Author:** ![ericpietro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpietro/32/9685_2.png) [@ericpietro](https://discuss.elastic.co/u/ericpietro)\
**Post date:** [February 24, 2017, 8:05am UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/3 "2017-02-24T08:05:34Z")

</div>

> [@jkuang](#):
>
> GET /idx\_mys\_pmm\_iis-2017.02/\_settings

hi Jimmy, ty for answering

this is the settings :  
{  
"idx\_mys\_pmm\_iis-2017.02": {  
"settings": {  
"index": {  
"creation\_date": "1486557770568",  
"refresh\_interval": "-1",  
"number\_of\_shards": "5",  
"number\_of\_replicas": "1",  
"uuid": "1QzkCRCJRDyjC58C\_MUf1g",  
"version": {  
"created": "2030399"  
}  
}  
}  
}  
}

---

<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:** [February 24, 2017, 8:54am UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/4 "2017-02-24T08:54:30Z")

</div>

> [@ericpietro](#):
>
> "refresh\_interval": "-1",

You have disabled automatic refreshes, so there is no defined time limit for when all results will be made searchable. This mode is often used during bulk load, but requires a manual refresh or a change to the setting at the end. If you want to optimise for indexing performance, but do not have clearly defined bulk loads after which you can refresh, you can instead set this to 10 or 30 seconds and still see a performance benefit, while avoiding any manual steps being required.

---

<div class="post-metadata">

**Author:** ![ericpietro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpietro/32/9685_2.png) [@ericpietro](https://discuss.elastic.co/u/ericpietro)\
**Post date:** [February 24, 2017, 9:27am UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/5 "2017-02-24T09:27:54Z")

</div>

ok ty christian.  
i will change this refresh\_interval setting.  
can i say this :  
the more the throuput of new documents is big, the more the value of the refresh\_interval is high (ex: 10, 20 or 30 s)  
but if you index a few documents by sec, u can set refresh\_interval to 1s for example.  
Am i wrong ?

---

<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:** [February 24, 2017, 11:39am UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/6 "2017-02-24T11:39:22Z")

</div>

If indexing is light, the default value of 1s should be fine.

---

<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:** [March 24, 2017, 11:39am UTC](https://discuss.elastic.co/t/number-of-docs-differents-between-primary-shards-and-replicas/76228/7 "2017-03-24T11:39:52Z")

</div>

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