# Terms\_stats facet & script\_field?

**URL:** <https://discuss.elastic.co/t/terms-stats-facet-script-field/9941>\
**Category:** Elasticsearch\
**Created:** [December 5, 2012, 12:09am UTC](https://discuss.elastic.co/t/terms-stats-facet-script-field/9941 "2012-12-05T00:09:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [December 5, 2012, 12:09am UTC](https://discuss.elastic.co/t/terms-stats-facet-script-field/9941/1 "2012-12-05T00:09:09Z")

</div>

Unlike the "terms" facet, the "terms\_stats" facet doesn't appear to support  
using a "script\_field" instead of a "key\_field". Is this simply a missing  
feature, or is this not practical (or is there a better way to accomplish  
this)?

I'm trying to use a facet to average numeric values either by hour-of-day,  
day-of-week or by month-of-year.

--

---

<div class="post-metadata">

**Author:** ![Valentin\_Pletzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/valentin_pletzer/32/105548_2.png) [@Valentin\_Pletzer](https://discuss.elastic.co/u/Valentin_Pletzer)\
**Post date:** [December 5, 2012, 7:22am UTC](https://discuss.elastic.co/t/terms-stats-facet-script-field/9941/2 "2012-12-05T07:22:15Z")

</div>

Maybe this facet plugin can help  
you? [GitHub - bleskes/elasticfacets: A set of facets and related tools for ElasticSearch](https://github.com/bleskes/elasticfacets)

On Wednesday, December 5, 2012 1:09:09 AM UTC+1, Eric Jain wrote:

> Unlike the "terms" facet, the "terms\_stats" facet doesn't appear to  
> support using a "script\_field" instead of a "key\_field". Is this simply a  
> missing feature, or is this not practical (or is there a better way to  
> accomplish this)?
> 
> I'm trying to use a facet to average numeric values either by hour-of-day,  
> day-of-week or by month-of-year.

--

---

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [December 5, 2012, 7:30am UTC](https://discuss.elastic.co/t/terms-stats-facet-script-field/9941/3 "2012-12-05T07:30:25Z")

</div>

On Tue, Dec 4, 2012 at 11:22 PM, Valentin [pletzer@gmail.com](mailto:pletzer@gmail.com) wrote:

> Maybe this facet plugin can help you?  
> [GitHub - bleskes/elasticfacets: A set of facets and related tools for ElasticSearch](https://github.com/bleskes/elasticfacets)

I don't think so (need to get e.g. the average value of a field across  
all Mondays), but thanks.

--

---

<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:01am UTC](https://discuss.elastic.co/t/terms-stats-facet-script-field/9941/4 "2017-07-06T03:01:27Z")

</div>


