Suppose there are there es data node : nodeA, nodeB, nodeC, and a index tweet with 1 primary shard and 2 replicas and no automatic refresh setting, it will result the primary shard in nodeA, the replica1 in nodeB, the replica1 in nodeC, so I can connect to any node for querying。
My question is when I called refresh for tweet after indexed 10 docs , while there are three thread connected to the three different node for same query , like
thread1 -> nodeA
thread2 -> nodeB
thread3 -> nodeC
is it possible nodeA refreshed first and the query returned 10 records, meanwhile nodeB has not yet refreshed and the query returned 0 records?
If it's possible, is there a option for refresh to block the search request until all shard and replicas refresed?
Yes.
There isn't an option to block concurrent searches behind the refresh. You'd have to do that yourself. In 5.0 there is any option on index/update/delete that'll block until the change made by that request is visible, though I don't know if it is useful for you: Where are my documents?<br>Refreshing news... | Elastic Blog
Thanks for your reply.
Then, It seems that setPreference to primay when querying is my only solution.