Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): OpenSearch 2.16
Describe the issue:
My DSL to get top 5 common values for the field ‘Dest’ in database and thier percent of total:
common values for the field
GET /opensearch_dashboards_sample_data_flights/_search
{
"size": 0,
"aggs": {
"total_count": {
"global": {},
"aggs": {
"total_count_dest": {
"value_count": {
"field": "Dest"
}
}
}
},
"top_dest": {
"terms": {
"field": "Dest",
"size": 5,
"order": {
"_count": "desc"
}
},
"aggs": {
"percent_of_total": {
"bucket_script": {
"buckets_path": {
"count": "_count",
"total": "total_count['total_count_dest']"
},
"script": "params.count / params.total * 100"
}
}
}
}
}
}
Configuration:
Relevant Logs or Screenshots:
But I got error:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: No aggregation found for path [total_count['total_count_dest']];"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: No aggregation found for path [total_count['total_count_dest']];"
},
"status": 400
}
Help my change my dsl to return data as expect. Thank very much.