# Terms-stats facet and aggregation

**URL:** <https://discuss.elastic.co/t/terms-stats-facet-and-aggregation/7916>\
**Category:** Elasticsearch\
**Created:** [May 30, 2012, 5:52pm UTC](https://discuss.elastic.co/t/terms-stats-facet-and-aggregation/7916 "2012-05-30T17:52:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seb\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seb_2/32/1419_2.png) [@seb\_2](https://discuss.elastic.co/u/seb_2)\
**Post date:** [May 30, 2012, 5:52pm UTC](https://discuss.elastic.co/t/terms-stats-facet-and-aggregation/7916/1 "2012-05-30T17:52:05Z")

</div>

Hi

I have a question, I don'r know if it's possible  
I use Terms Stats Facet ([http://www.elasticsearch.org/guide/reference/](http://www.elasticsearch.org/guide/reference/)  
api/search/facets/terms-stats-facet.html) and I'd like to get more  
information.

For example, the demo code on the doc is

```
"facets" : {
    "tag_price_stats" : {
        "terms_stats" : {
            "key_field" : "tag",
            "value_field" : "price"
        }
    }
}

```

suppose that we have tag and price in the index  
If now we also have category, I'd like to know for each terms\_stats  
facet value the list of categories included in the facet.

something like this

```
{
    "term" : "book", ## book is the tag
    "count" : 10,
    "total_count" : 10,
    "min" : 170.489,
    "max" : 170.514,
    "total" : 1705.0390000000002,
    "mean" : 170.50390000000002
    "category": ["ruby", "java", "C++] ## What I'd like to have
  },

```

Is that possible?

thanks a lot

---

<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:** [July 6, 2017, 3:26am UTC](https://discuss.elastic.co/t/terms-stats-facet-and-aggregation/7916/2 "2017-07-06T03:26:14Z")

</div>


