I have a document structure which looks something like
{
"orderNo": "123O",
"tradeNo": "567T",
"orderConsideration": 10,
"children": [{
"orderNo": "124O",
"tradeNo": "566T",
"orderConsideration": 15,
"children": [{
"orderNo": "126O",
"tradeNo": "565T",
"orderConsideration": 20,
"children": [{
"orderNo": "127O",
"tradeNo": "564T",
"orderConsideration": 25,
"children": [{
"orderNo": "128O",
"tradeNo": "563T",
"orderConsideration": 30,
"children": []
}]
}]
}]
}]
}
And I can send a search request something like this:
GET /data_nested_test/_search
{
"size": 0,
"aggs": {
"group_by_nested": {
"nested": {
"path": "children"
},
"aggs": {
"sum_by_consideration": {
"sum": {
"field": "children.orderConsideration"
}
}
}
}
}
}
But this will only match on the first level of the path, is there a way short of having to create a nested aggregation for every level (it could be 10 deep or maybe more) for elastic to follow the path of the nested document until it reaches the end and collect each field that it finds?
So the answer above would be 100?
Thanks!