-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Analytics/AggregationsAggregationsAggregationsTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)Meta label for analytical engine team (ESQL/Aggs/Geo)
Description
Elasticsearch version (bin/elasticsearch --version): 7.6.1
Plugins installed: [none]
JVM version (java -version): OpenJDK 11.0.6
OS version (uname -a if on a Unix-like system): Ubuntu 18.04
Aggregation ordering path not working when we try to aggregate parent/child documents. Elastic search return status 500
Expected result that elastic search return ordered aggregations
Steps to reproduce:
- Create index
PUT my_index
{
"mappings": {
"properties": {
"employer_id": {
"type": "integer"
},
"price": {
"type": "integer"
},
"join_field": {
"type": "join",
"relations": {
"order": "item"
}
}
}
}
}
- Problem query:
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
}
The same functionality worked fine on Elasticsearch 5.3
Example:
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"
}
}
}
}
}
}
}
}
mcheban, alehbakuryn, nikolaened, vertden, Donila and 4 more
Metadata
Metadata
Assignees
Labels
:Analytics/AggregationsAggregationsAggregationsTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)Meta label for analytical engine team (ESQL/Aggs/Geo)