# Elasticsearch : Replace aggregation with fieldsstats

**URL:** <https://discuss.elastic.co/t/elasticsearch-replace-aggregation-with-fieldsstats/70529>\
**Category:** Elasticsearch\
**Created:** [January 4, 2017, 9:27am UTC](https://discuss.elastic.co/t/elasticsearch-replace-aggregation-with-fieldsstats/70529 "2017-01-04T09:27:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [January 4, 2017, 9:27am UTC](https://discuss.elastic.co/t/elasticsearch-replace-aggregation-with-fieldsstats/70529/1 "2017-01-04T09:27:23Z")

</div>

How to use the field data API to get the frequency count of a search query. EX: "aggs" : { "my-terms" : {"filters" : { "filters" : { "name" : { "term" : { "zip\_key" : "20156" }}}}}}.

How to replace the same using field stats API without using aggregation.

Or is there any other solution to get term frequency count other than aggregation

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 5, 2017, 1:54am UTC](https://discuss.elastic.co/t/elasticsearch-replace-aggregation-with-fieldsstats/70529/2 "2017-01-05T01:54:04Z")

</div>

You cannot use filters with field stats - [https://www.elastic.co/guide/en/elasticsearch/reference/5.1/search-field-stats.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/search-field-stats.html)

---

<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:** [February 2, 2017, 1:54am UTC](https://discuss.elastic.co/t/elasticsearch-replace-aggregation-with-fieldsstats/70529/3 "2017-02-02T01:54:38Z")

</div>

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