I have documents like this in my index:
{
"time": "2015-03-24T08:24:55.9056988",
"msg": {
"corrupted": false,
"stat": {
"fileSize": 10186,
"stages": [
{
"stage": "queued",
"duration": 420
},
{
"stage": "validate",
"duration": 27
},
{
"stage": "cacheFile",
"duration": 87
},
{
"stage": "sendResult",
"duration": 1332
}
]
}
}
}
I'd like to calculate sum(msg.stat.stages.duration) grouped by
msg.stat.stages.stage.
I tried the following:
{
"size": 0,
"aggs":
{
"1":
{
"terms": { "field": "msg.stat.stages.stage" },
"aggs":
{
"2":
{
"nested": { "path": "stat.stages" },
"aggs":
{
"3": {
"sum": {
"field": "stat.stages.duration"
}
}
}
}
}
}
},
"query": {
"match_all": {}
}
}
and got:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0,
"hits": []
},
"aggregations": {
"1": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"2": {
"doc_count": 0
},
"key": "cachefile",
"doc_count": 1
},
{
"2": {
"doc_count": 0
},
"key": "queued",
"doc_count": 1
},
{
"2": {
"doc_count": 0
},
"key": "sendresult",
"doc_count": 1
},
{
"2": {
"doc_count": 0
},
"key": "validate",
"doc_count": 1
}
]
}
}
}
which is not what I expected. Any ideas?
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/22173f85-6d94-4b29-a9f5-b13c46a4850d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.