How to retrieve field statistics now that _field_stats is deprecated


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.

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.

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 ... :slight_smile:

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