# Average on string values containing % in elasticsearch

**URL:** <https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709>\
**Category:** Elasticsearch\
**Created:** [May 24, 2014, 3:22pm UTC](https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709 "2014-05-24T15:22:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [May 24, 2014, 3:22pm UTC](https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709/1 "2014-05-24T15:22:15Z")

</div>

Hi,

I have a field of type string in documents and there are values like  
"CPU\_USED": "0.02%". I want to do average of all the values using some  
filters. I tried with below but getting error. Please suggest how to do  
this.

POST /virtualmachines/\_search  
{  
"query" : {  
"filtered" : {  
"query" : { "match" : {  
"CLOUD\_TYPE" : "CLOUDSTACK"  
}},  
"filter" : {  
"range" : { "NODE\_CREATE\_TIME" : { "from" : "2014-05-22  
14:11:35", "to" : "2014-05-22 14:33:35" }}  
}  
}  
},  
"aggs" : {  
"avg\_cpu" : { "avg" : { "script" : "doc['CPU\_USED'].value" } }  
}  
}

_error :_  
AggregationExecutionException[Unsupported script value [0.03%]]

--  
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/02462a04-aedb-4049-b650-9def0de582cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/02462a04-aedb-4049-b650-9def0de582cb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [May 25, 2014, 3:13pm UTC](https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709/2 "2014-05-25T15:13:10Z")

</div>

any suggestion ?

Subhadip

--  
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/71bcd469-d1b7-4b37-87fd-b7100cb9e5ad%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/71bcd469-d1b7-4b37-87fd-b7100cb9e5ad%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [May 26, 2014, 6:55am UTC](https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709/3 "2014-05-26T06:55:22Z")

</div>

Any help on this ?

--  
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/cc52b02a-f71f-4bfa-9219-5f5a3a6b25b2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc52b02a-f71f-4bfa-9219-5f5a3a6b25b2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 26, 2014, 6:57am UTC](https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709/4 "2014-05-26T06:57:11Z")

</div>

Patience, it has been the weekend after all 🙂

Regards,  
Mark Walkom

Infrastructure Engineer  
Campaign Monitor  
email: [markw@campaignmonitor.com](mailto:markw@campaignmonitor.com)  
web: [www.campaignmonitor.com](http://www.campaignmonitor.com)

On 26 May 2014 16:55, Subhadip Bagui [i.bagui@gmail.com](mailto:i.bagui@gmail.com) wrote:

> Any help on this ?
> 
> --  
> 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/cc52b02a-f71f-4bfa-9219-5f5a3a6b25b2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc52b02a-f71f-4bfa-9219-5f5a3a6b25b2%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/cc52b02a-f71f-4bfa-9219-5f5a3a6b25b2%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/cc52b02a-f71f-4bfa-9219-5f5a3a6b25b2%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAEM624Y3WkfBeLN2jFSj8t6M\_vi6ddgTWoU1%3Dt2wfNf%2BhmA%2Bxg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEM624Y3WkfBeLN2jFSj8t6M_vi6ddgTWoU1%3Dt2wfNf%2BhmA%2Bxg%40mail.gmail.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:27am UTC](https://discuss.elastic.co/t/average-on-string-values-containing-in-elasticsearch/17709/5 "2017-07-06T01:27:01Z")

</div>


