# How to get average, max, min etc. from a group of object

**URL:** <https://discuss.elastic.co/t/how-to-get-average-max-min-etc-from-a-group-of-object/15628>\
**Category:** Elasticsearch\
**Created:** [February 5, 2014, 7:05pm UTC](https://discuss.elastic.co/t/how-to-get-average-max-min-etc-from-a-group-of-object/15628 "2014-02-05T19:05:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carmine\_Giangregorio](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@Carmine\_Giangregorio](https://discuss.elastic.co/u/Carmine_Giangregorio)\
**Post date:** [February 5, 2014, 7:05pm UTC](https://discuss.elastic.co/t/how-to-get-average-max-min-etc-from-a-group-of-object/15628/1 "2014-02-05T19:05:00Z")

</div>

Hi,  
I'm using an elasticsearch db to store data for benchmarks.  
I need to calculate and retrieve the average, max, min, etc. of a Group of  
values.

I have something like:

Index = "myindex"  
Type = "mytype"

Each object has 3 fields:

"load\_time", "execution\_time", "log\_time".

I then run the benchmark and db is populated with hundreds of records. Now,  
I would retrieve the average, the max and the min value for each field.  
What query should I run?  
I tried with statistical facet but I Always get a "unreognized token  
exception"...

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8f0b155c-34d9-45d8-a3e6-c41f3311720b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8f0b155c-34d9-45d8-a3e6-c41f3311720b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 6, 2014, 10:26am UTC](https://discuss.elastic.co/t/how-to-get-average-max-min-etc-from-a-group-of-object/15628/2 "2014-02-06T10:26:50Z")

</div>

Hey,

can you provide some sample data, your mapping, the query and the concrete  
error message, so others can reproduce/better spot your problem?  
Statistical facet sounds good here, so the problem must be somewhere else...

--Alex

On Wed, Feb 5, 2014 at 8:05 PM, Carmine Giangregorio [carminexx@gmail.com](mailto:carminexx@gmail.com)wrote:

> Hi,  
> I'm using an elasticsearch db to store data for benchmarks.  
> I need to calculate and retrieve the average, max, min, etc. of a Group of  
> values.
> 
> I have something like:
> 
> Index = "myindex"  
> Type = "mytype"
> 
> Each object has 3 fields:
> 
> "load\_time", "execution\_time", "log\_time".
> 
> I then run the benchmark and db is populated with hundreds of records.  
> Now, I would retrieve the average, the max and the min value for each field.  
> What query should I run?  
> I tried with statistical facet but I Always get a "unreognized token  
> exception"...
> 
> Thanks!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/8f0b155c-34d9-45d8-a3e6-c41f3311720b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8f0b155c-34d9-45d8-a3e6-c41f3311720b%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-R1kuiihjbLWKQpp6s8XxxRCutCN%2BccsN5V2EZM%2BRsTg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-R1kuiihjbLWKQpp6s8XxxRCutCN%2BccsN5V2EZM%2BRsTg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:52am UTC](https://discuss.elastic.co/t/how-to-get-average-max-min-etc-from-a-group-of-object/15628/3 "2017-07-06T01:52:03Z")

</div>


