Uses of Index Stats API

Hi all:)
I am writing a new feature to perform query profiling on the fly and I came across the Index Stats API.
After trying to use this API’s groups capability it seems it is only valid on the shards level, whereas, on the indices level you get a sum of the shards level data.

example:
for one index 3 shards, send a query with “stats”: [“group1”]. Let’s say it returns within 100msec.
then send a GET “/_stats/search?groups=group1” call and receive something like:

.
.
.
"groups": {
                    "group1": {
                        "query_total": 3,
                        "query_time_in_millis": 250,
                        "query_current": 0,
                        "fetch_total": 0,
                        "fetch_time_in_millis": 0,
                        "fetch_current": 0,
                        "scroll_total": 0,
                        "scroll_time_in_millis": 0,
                        "scroll_current": 0,
                        "suggest_total": 0,
                        "suggest_time_in_millis": 0,
                        "suggest_current": 0
                    }
                }
.
.
.

query_total is 3 because there are 3 shards, and the query_time_in_millis is higher than 100msec because it is a sum of the time it took for each shard and not the max.

Does anyone use the data at the indices/cluster levels in some way?
I am asking because it looks like a bug on the one hand, but on the other hand, it is there from day 1…

2 Likes

opened this as an issue:
https://github.com/opensearch-project/OpenSearch/issues/852