Avg aggregation on string values

Hi,

I've below kind of documents in elasticsearch which is coming from 3rd
party api and there are values upon which I want to do aggregation.

{
"_index": "virtualmachines",
"_type": "nodes",
"_id": "103",
"_score": 1,
"_source": {
"NODE_ID": "12335",
"CLOUD_TYPE": "AWS-EC2",
"NODE_GROUP_NAME": "MYSQL",
"NODE_CPU": "4GHZ",
"NODE_HOSTNAME": "cloud.aricent.com",
"NODE_NAME": "aws-node1",
"NODE_PRIVATE_IP_ADDRESS": "10.123.124.126",
"NODE_PUBLIC_IP_ADDRESS": "125.31.108.73",
"NODE_INSTANCE_ID": "aws111",
"NODE_STATUS": "INACTIVE",
"NODE_CATEGORY_ID": "2",
"NODE_CREATE_TIME": "2014-05-22 14:40:35",
"CPU_SPEED": "500",
"MEMORY": 512,
"CPU_USED": "0.02%"
}

Here is my code from where I do aggregation

SearchResponse response = client.prepareSearch("virtualmachines")
.setTypes("nodes").setQuery(QueryBuilders.matchAllQuery())
//.addAggregation(AggregationBuilders.avg("mem_average").field("CPU_SPEED"))
.addAggregation(AggregationBuilders.avg("mem_average").script("doc['CPU_USED'].value"))
.execute().actionGet();
error :
Exception in thread "main"
org.elasticsearch.transport.TransportSerializationException: Failed to
deserialize exception response from stream
at
org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:169)

the mapping for CPU_SPEED is
"CPU_USED": {
"type": "string"
}

If I change the mapping to type long then the same is working. Is there any
way to get the string value and do the aggregation.

Thanks,
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bff62cd0-65af-4090-90d3-2d14aeb3363a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

please suggest...

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/cef8d6e2-95f7-4040-9683-df188f1717cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.