Getting number of indexed documents when there is a replica

Hi,

I'm trying to calculate the indexing rate of my ES (version 8.8.0), and I've been using the API below to do that when I set replica = 0.

GET <index_name>/_stats/indexing?filter_path=indices.*.total.indexing.index_total

I would get the difference of the index_total values within a time period, and then divide by the time period to get the indexing rate.

When I set replica = 1, I get approximately 35-40% higher indexing rate than when no replica was set. Is this because the API included the documents indexed in the replica? If so, how do I get the indexing rate for only the primary shards then?

Thank you.

GET <index_name>/_stats/indexing?filter_path=indices.*.primaries.indexing.index_total

1 Like