Does index operation (refresh:true) return before or after refresh?

Assuming version 2.4: does index operation with refresh set to true return after or before the refresh is done?
Doc is not clear about this

It returns after forcing a refresh, so the refresh completes before the operation returns.

Also, it's worth mentioning that adding ?refresh=true to each indexing operation is a very bad idea, as it will cause segments to be written out with a single document all the time and slow down indexing substantially.

Thank you for your reply.

The application I use Elasticsearch in has periodic refresh set to 1s.
According to Marvel there are 3 indexing operations a second in average with peaks at 20/s.
I assume index with refresh=true will refresh just the shard doc is routed to.
There are 16 shards in total + 1x replica. So I assume not much should change in terms of refresh rate and in turn, performance should not degradate.
Application requires consistency of data and uses ES for listings. Having data available for search immediately after index will cover one of consistency gaps.

If you're able, something that would benefit you would be to upgrade to Elasticsearch 5.x, in which case you can use ?refresh=wait_for which will wait for a natural refresh without triggering one explicitly.

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