Aggregation Filter Sort - InternalFilter cannot be cast to class InternalMultiBucketAggregation

I think the error is due to the depth of your query's aggregations.

I noticed that you use a filter, so I used it in the query and removed it from the aggregation.
I don't know if it's what you expected but the query returned results

{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "gender": "women"
          }
        }
      ]
    }
  },
  "aggs": {
    "group_by_names": {
      "terms": {
        "field": "playerid"
      },
      "aggs": {
        "sum_of_runs": {
          "sum": {
            "field": "runs"
          }
        },
        "top_runs_by_player": {
          "bucket_sort": {
            "sort": [
              { "sum_of_runs": { "order": "asc" } } 
            ]
          }
        }
      }
    }
  }
}
1 Like