How to sort keyword/text fields on aggregation results

Hi Everyone!

I have a aggregation results and I need to sort aggregation data using Elasticsearch.Net. When i'm trying using terms aggregation i'm getting this error "buckets_path must reference either a number value or a single value numeric metric aggregation, got: [UnmappedTerms] at aggregation".

Numeric columns are sorting correctly.

Here my query i'm using in ES head:

{
  "track_total_hits": true,
  "aggs": {
    "UniqueJobs": {
      "aggs": {
        "top_grades": {
          "top_hits": {
            "size": 1,
            "_source": {
              "includes": [
                "assetId",
                "jobId",
                "name",
                
              ]
            }
          }
        },
        "commits": {
          "terms": {
            "field": "name",
            "size": 10000
          }
        },
        "bucket_sort": {
          "bucket_sort": {
            "from": 0,
            "size": 50,
            "sort": [
              {
                "commits": {
                  "order": "asc"
                }
              }
            ]
          }
        }
      },
      "terms": {
        "field": "JobId",
        "size": 100000
      }
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "analyze_wildcard": true,
            "default_operator": "and",
            "query": "John AND test AND portfolio*"
          }
        }
      ]
    }
  }
}

Thanks in advance!

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