Thanks a lot Ivan. Will try with Java API as u suggested.

One more doubt. There is a field in my document like "CPU_USED": "0.03%"
Can we do aggregation avg on this field ? I tried but got exception like 
below as this was a string field. Can u please suggest.

"reason": "QueryPhaseExecutionException[[virtualmachines][2]: 
query[filtered(CLOUD_TYPE:cloudstack)->cache(NODE_CREATE_TIME:[1400767895000 
TO 1400769215999])],from[0],size[0]: Query Failed [Failed to execute main 
query]]; nested: AggregationExecutionException[Unsupported script value 
[0.03]]; "
*Query :*
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_grade" : { "avg" : { "script" : "doc['CPU_USED'].value" } }
    },
    "size": 0
}

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/bd12c67b-9369-4231-90ec-a818a6e9be9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to