Index refresh and replication behaviour

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

On the other hand, there is information indicating that 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.

@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?

Yes.

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

1 Like