Elasticsearch: Should not be possible to use Bucket Script in term order by in Grafana 8.0.6

Hello,

I have installed grafana 8.0.6. I have created a Stat panel with ElasticSearch data source with the following query. After creating Bucket script when I tried to use in order by option with reference to bucket script then It is giving below error:

"root_cause": [
{
“type”: “aggregation_execution_exception”,
“reason”: “Invalid aggregation order path [7]. The provided aggregation [7] either does not exist or is a pipeline aggregation and cannot be used to sort the buckets.
}

Can anyone please help me with this? As my requirement is to order data in descending order based on the bucket script. Is this an issue on grafana or I am doing something wrong.


Any updates on this? Can anyone please help me to sort out this