Aggregation nesting
wanganhong opened this issue · 2 comments
wanganhong commented
How can i make an aggregations like the following examples?
"aggs": {
"results": {
"date_histogram": {
"field": "time",
"interval": 'day'
},
"aggs": {
"to-child": {
"children": {
"type": "status"
},
"aggs": {
"inner": {
"terms": {
"field": "handle_flag",
"size": 10
}
}
}
}
}
}
}
wanganhong commented
I got it!
Used:
aggs1 = Aggregate.date_histogram('results', 'time', 'day')
aggs2 = Aggregate.children('to-child', 'status')
aggs3 = Aggregate.terms('inner', 'handle_flag')
aggs2.aggregate(aggs3)
aggs1.aggregate(aggs2)
print aggs1.dict()
Is there a simpler way?
Fizzadar commented
@wanganhong unfortunately not; for more complex aggregations I never managed to come up with a decent API! Sadly I no longer have any time to maintain this project beyond bugs; feel free to PR though :)