# Can I get term facetted statistics?

**URL:** <https://discuss.elastic.co/t/can-i-get-term-facetted-statistics/10384>\
**Category:** Elasticsearch\
**Created:** [January 17, 2013, 6:46am UTC](https://discuss.elastic.co/t/can-i-get-term-facetted-statistics/10384 "2013-01-17T06:46:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iwein](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iwein/32/2531_2.png) [@Iwein](https://discuss.elastic.co/u/Iwein)\
**Post date:** [January 17, 2013, 6:46am UTC](https://discuss.elastic.co/t/can-i-get-term-facetted-statistics/10384/1 "2013-01-17T06:46:09Z")

</div>

I'm trying to compute a minimum for a certain field by term.

I've added a few documents with a 'd' string and a 'p' number. For each d,  
I want to have the minimum p. Is this possible? Below is what I tried, but  
that totally ignores the terms...

curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"b", "p":2}'  
curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"b", "p":3}'  
curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"c", "p":2}'

curl -XGET '[http://localhost:9200/foo/\_search?pretty=true](http://localhost:9200/foo/_search?pretty=true)' -d '{"fields": ["d" , "p"],"query": {"match\_all": {}},"facets": {"f1": {"terms": {"field": "d" }, "statistical":"p"}'

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2013, 8:42am UTC](https://discuss.elastic.co/t/can-i-get-term-facetted-statistics/10384/2 "2013-01-17T08:42:02Z")

</div>

Try this.  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html)  
[http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html)

curl -XGET '[http://localhost:9200/foo/\_search?pretty=true](http://localhost:9200/foo/_search?pretty=true)' -d '{"felds": ["d" ,  
"p"],"query": {"match\_all": {}},"facets": {"f1": {"terms\_stats": {"key\_field":  
"d","value\_field":"p" }}}}'

Le 17 janvier 2013 à 07:46, Iwein [iwein.fuld@gmail.com](mailto:iwein.fuld@gmail.com) a écrit :

> I'm trying to compute a minimum for a certain field by term.
> 
> I've added a few documents with a 'd' string and a 'p' number. For each d, I  
> want to have the minimum p. Is this possible? Below is what I tried, but that  
> totally ignores the terms...
> 
> curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"b", "p":2}'  
> curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"b", "p":3}'  
> curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"c", "p":2}'
> 
> curl -XGET '[http://localhost:9200/foo/\_search?pretty=true](http://localhost:9200/foo/_search?pretty=true)' -d '{"fields":  
> ["d" , "p"],"query": {"match\_all": {}},"facets": {"f1": {"terms": {"field":  
> "d" }, "statistical":"p"}'
> 
> --

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![Iwein](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iwein/32/2531_2.png) [@Iwein](https://discuss.elastic.co/u/Iwein)\
**Post date:** [January 18, 2013, 10:06am UTC](https://discuss.elastic.co/t/can-i-get-term-facetted-statistics/10384/3 "2013-01-18T10:06:58Z")

</div>

You rock, thanks!

Iwein

On Thursday, January 17, 2013 9:42:02 AM UTC+1, David Pilato wrote:

> Try this.  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html)
> 
> curl -XGET '[http://localhost:9200/foo/\_search?pretty=true](http://localhost:9200/foo/_search?pretty=true)' -d '{"felds":  
> ["d" , "p"],"query": {"match\_all": {}},"facets": {"f1": {"terms\_stats":  
> {"key\_field": "d","value\_field":"p" }}}}'
> 
> Le 17 janvier 2013 à 07:46, Iwein \<[iwein...@gmail.com](mailto:iwein...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> I'm trying to compute a minimum for a certain field by term.
> 
> I've added a few documents with a 'd' string and a 'p' number. For each  
> d, I want to have the minimum p. Is this possible? Below is what I tried,  
> but that totally ignores the terms...
> 
> curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"b", "p":2}'  
> curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"b", "p":3}'  
> curl -XPOST '[http://localhost:9200/foo/test](http://localhost:9200/foo/test)' -d '{"d":"c", "p":2}'
> 
> curl -XGET '[http://localhost:9200/foo/\_search?pretty=true](http://localhost:9200/foo/_search?pretty=true)' -d '{"fields": ["d" , "p"],"query": {"match\_all": {}},"facets": {"f1": {"terms": {"field": "d" }, "statistical":"p"}'
> 
> --
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<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, 2:55am UTC](https://discuss.elastic.co/t/can-i-get-term-facetted-statistics/10384/4 "2017-07-06T02:55:48Z")

</div>

Closed on July 6, 2017, 2:55am UTC


