# How to compute average search request cost time through indices stats api

**URL:** https://discuss.elastic.co/t/how-to-compute-average-search-request-cost-time-through-indices-stats-api/149285
**Category:** Elasticsearch
**Created:** [September 20, 2018, 12:04pm UTC](https://discuss.elastic.co/t/how-to-compute-average-search-request-cost-time-through-indices-stats-api/149285 "2018-09-20T12:04:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Integret](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/integret/32/32857_2.png) [@Integret](https://discuss.elastic.co/u/Integret)
#### Post date: [September 20, 2018, 12:04pm UTC](https://discuss.elastic.co/t/how-to-compute-average-search-request-cost-time-through-indices-stats-api/149285/1 "2018-09-20T12:04:28Z")

</div>

i call the /{index}/\_stats/ interface two times, and try to compute average search cost time use:

（total.search.query\_time\_in\_millis 2 - total.search.query\_time\_in\_millis 1）/ ( total.search.query\_total 2 - total.search.query\_total 1)  
+  
（total.search.fetch\_time\_in\_millis 2 - total.search.fetch\_time\_in\_millis 1）/ ( total.search.fetch\_total 2 - total.search.fetch\_total 1)

however find query + fetch is only 0.1ms, this is much smaller than the Request Time in Kibana (6ms) which i think is right.

how can i compute average search request cost time through indices stats api ?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 18, 2018, 12:04pm UTC](https://discuss.elastic.co/t/how-to-compute-average-search-request-cost-time-through-indices-stats-api/149285/2 "2018-10-18T12:04:30Z")

</div>

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