Sort aggregation by string

Hi all and sorry for my poor english.
I'd like to sort by creation (string) field this query

GET /profiles/_search
{
    "aggs": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
                {  
                  "range": {
                  "creation": {
                    "from": "2017-03-11 T 00:00:00.000+0000",
                    "to": "2021-03-12 T 00:00:00.000+0000"}        
                  }
                } ,
                {
                  "terms":
                  {
                    "type" : ["default"]
                  }
                }
          ]          
        }        
      },
      "aggs": {
        "type_profile": {
          "terms": {
            "field": "type" 
          },
          "aggs":{
              "date_creation": {
                  "terms": {
                    "field": "creation"   
                  }  
                
              }
          }
          
        } 
      }      
    }     
  } ,
  "size": 0 
}

I tried using bucket_sort but with no success
Thanks in advance

What do you want to sort? The hits? Or the aggregations?

I found solution using
"order": { "_key" : "desc" }
in the deepest terms aggs

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.