# How to retrieve field statistics now that \_field\_stats is deprecated

**URL:** <https://discuss.elastic.co/t/how-to-retrieve-field-statistics-now-that-field-stats-is-deprecated/104803>\
**Category:** Elasticsearch\
**Created:** [October 22, 2017, 2:23pm UTC](https://discuss.elastic.co/t/how-to-retrieve-field-statistics-now-that-field-stats-is-deprecated/104803 "2017-10-22T14:23:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shai\_Erera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shai_erera/32/13492_2.png) [@Shai\_Erera](https://discuss.elastic.co/u/Shai_Erera)\
**Post date:** [October 22, 2017, 2:23pm UTC](https://discuss.elastic.co/t/how-to-retrieve-field-statistics-now-that-field-stats-is-deprecated/104803/1 "2017-10-22T14:23:10Z")

</div>

Hi

I read that \_field\_stats is deprecated and that I should use \_field\_caps or min/max aggregations. I use this API today to retrieve field statistics such as sum\_ttf and sum\_docfreq. From \_field\_caps docs, I don't see how I can obtain these statistics. And I don't see how I can compute them using min/max aggregations too...

Am I missing something?

As a workaround, I use the \_termvector API, sending a dummy document and requesting field statistics, but was wondering if there's a better way to retrieve those stats.

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [October 26, 2017, 9:50am UTC](https://discuss.elastic.co/t/how-to-retrieve-field-statistics-now-that-field-stats-is-deprecated/104803/2 "2017-10-26T09:50:10Z")

</div>

Hi Shai!

We removed field stats mostly because it had been built in order to let clients do things that should really be done by Elasticsearch, like filtering out shards that cannot match because their values do not intersect a filter of the query for instance. I'm wondering whether the same would apply in your case?

Using term vectors instead in the meantime sounds like an ok hack to me. I don't think there is any other way you could do it.

---

<div class="post-metadata">

**Author:** ![Shai\_Erera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shai_erera/32/13492_2.png) [@Shai\_Erera](https://discuss.elastic.co/u/Shai_Erera)\
**Post date:** [October 26, 2017, 9:53am UTC](https://discuss.elastic.co/t/how-to-retrieve-field-statistics-now-that-field-stats-is-deprecated/104803/3 "2017-10-26T09:53:06Z")

</div>

Thanks @jpountz, I use this API in order to retrieve index statistics, so that I can compute some local language models etc. on the client side. The things that I do cannot be done by ES today, and while they could be done in a plug-in. I currently am not able to upload custom plug-ins into my ES instance (on a cloud).

I wish that ES exposed such "expert" level APIs, even without promising back-compat ... 🙂

---

<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:** [November 23, 2017, 9:53am UTC](https://discuss.elastic.co/t/how-to-retrieve-field-statistics-now-that-field-stats-is-deprecated/104803/4 "2017-11-23T09:53:16Z")

</div>

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