# Index refresh and replication behaviour

**URL:** <https://discuss.elastic.co/t/index-refresh-and-replication-behaviour/363798>\
**Category:** Elasticsearch\
**Created:** [July 25, 2024, 3:24pm UTC](https://discuss.elastic.co/t/index-refresh-and-replication-behaviour/363798 "2024-07-25T15:24:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergii1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergii1/32/123391_2.png) [@Sergii1](https://discuss.elastic.co/u/Sergii1)\
**Post date:** [July 25, 2024, 3:24pm UTC](https://discuss.elastic.co/t/index-refresh-and-replication-behaviour/363798/1 "2024-07-25T15:24:16Z")

</div>

I am struggling to understand if the index refresh operation makes data available for search immediately on both primary and replica shards.

On one hand, it seems that replication and index refreshing are completely independent processes. This suggests that after a refresh, a document might be temporarily unavailable for search on a replica shard.

I found this information [here](https://discuss.elastic.co/t/how-refresh-works-between-primary-and-replica-shards/219181/2)

On the other hand, [there is information](https://github.com/elastic/elasticsearch/issues/31929#issuecomment-408744128) indicating that a refresh forces the replica to be updated at the same time as the primary shard.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 25, 2024, 3:39pm UTC](https://discuss.elastic.co/t/index-refresh-and-replication-behaviour/363798/2 "2024-07-25T15:39:08Z")

</div>

> [@Sergii1](#):
>
> a refresh forces the replica to be updated at the same time as the primary shard.

Well, technically not "at the same time" (this phrase doesn't even make sense in a distributed system) but as long as you refresh after indexing the doc on every shard copy then that doc will be visible to searches on all the shard copies.

---

<div class="post-metadata">

**Author:** ![Sergii1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergii1/32/123391_2.png) [@Sergii1](https://discuss.elastic.co/u/Sergii1)\
**Post date:** [July 25, 2024, 4:08pm UTC](https://discuss.elastic.co/t/index-refresh-and-replication-behaviour/363798/3 "2024-07-25T16:08:23Z")

</div>

@DavidTurner, thanks for the quick reply. But just to double-check if I understand correctly:

1. After an indexing request (POST /{target}/\_doc/?refresh=wait\_for) finishes, the document will be available for search on all related shards.

2. If I perform an index refresh manually (POST /{target}/\_refresh), will it yield the same result as in the first case?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 25, 2024, 4:19pm UTC](https://discuss.elastic.co/t/index-refresh-and-replication-behaviour/363798/4 "2024-07-25T16:19:26Z")

</div>

> [@Sergii1](#):
>
> After an indexing request (POST /{target}/\_doc/?refresh=wait\_for) finishes, the document will be available for search on all related shards.

Yes.

> [@Sergii1](#):
>
> If I perform an index refresh manually (POST /{target}/\_refresh), will it yield the same result as in the first case?

Yes, if you submit the refresh request _after_ you've received a response to the indexing request.
