# Script average value over hits

**URL:** https://discuss.elastic.co/t/script-average-value-over-hits/17461
**Category:** Elasticsearch
**Created:** [May 12, 2014, 2:47pm UTC](https://discuss.elastic.co/t/script-average-value-over-hits/17461 "2014-05-12T14:47:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jo\_Emil\_Holen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jo_emil_holen/32/857_2.png) [@Jo\_Emil\_Holen](https://discuss.elastic.co/u/Jo_Emil_Holen)
#### Post date: [May 12, 2014, 2:47pm UTC](https://discuss.elastic.co/t/script-average-value-over-hits/17461/1 "2014-05-12T14:47:48Z")

</div>

Hi!

I want to make a script that does some statistics, as how I understand it,  
ES don't do statistic the way I need it to.

The search I do returns multiple hits like  
this: [http://pastebin.com/UkQjDXhm](http://pastebin.com/UkQjDXhm)  
What I want to do is an average of time after 13:37 independent of date. So  
what I think would do it is creating a date object and push  
parseFloat(date.getMinutes()+"."+date.getSeconds()), and then average it in  
the end and put it into the response. Wrote it like javascript, but I  
assume MVEL is the fastest language, so I'd like to do it in MVEL.

Is this at all possible, or would I have to do it on the client side?

Regards Jo Emil

--  
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/d30345b1-8126-4d89-8fd9-2897695086a7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d30345b1-8126-4d89-8fd9-2897695086a7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:30am UTC](https://discuss.elastic.co/t/script-average-value-over-hits/17461/2 "2017-07-06T01:30:07Z")

</div>


