Hi All,
We try to migrate to ES 7.X from ES 5.3 and found next problem:
In ES 7.6.1 Aggregation ordering path not working when we try to aggregate parent/child documents
In ES 5.3 Its working fine
ES 7.6.1 Example:
PUT my_index
{
"mappings": {
"properties": {
"employer_id": {
"type": "integer"
},
"price": {
"type": "integer"
},
"join_field": {
"type": "join",
"relations": {
"order": "item"
}
}
}
}
}
GET my_index/_search
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"relation": "order"
}
}
]
}
}
}
},
"aggs": {
"employer": {
"terms": {
"field": "employer_id",
"size": "50",
"order": {
"child_join>price_sum": "desc"
}
},
"aggs": {
"child_join": {
"children": {
"type": "item"
},
"aggs": {
"price_sum": {
"sum": {
"field": "price"
}
}
}
}
}
}
}
}
Response:
{
"error": {
"root_cause": [
{
"type": "aggregation_execution_exception",
"reason": "Invalid aggregation order path [child_join>price_sum]. Buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end. Sub-path [child_join] points to non single-bucket aggregation"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "my_index",
"node": "MMgye6_eSdqPGUc6buwxLQ",
"reason": {
"type": "aggregation_execution_exception",
"reason": "Invalid aggregation order path [child_join>price_sum]. Buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end. Sub-path [child_join] points to non single-bucket aggregation"
}
}
]
},
"status": 500
}
ES 5.3 Example works fine:
PUT my_index
{
"mappings": {
"order": {
"properties": {
"employer_id": {
"type": "integer"
}
}
},
"item": {
"properties": {
"price": {
"type": "integer"
}
},
"_parent": {
"type": "order"
}
}
}
}
GET my_index/order/_search
{
"aggs": {
"employer": {
"terms": {
"field": "employer_id",
"size": "50",
"order": {
"child_join>price_sum": "desc"
}
},
"aggs": {
"child_join": {
"children": {
"type": "item"
},
"aggs": {
"price_sum": {
"sum": {
"field": "price"
}
}
}
}
}
}
}
}
Any idea whats wrong or I am doing something wrong?