Sort on term sub aggregation field

Suppose I have the following query:

{
  "aggs": {
    "distinct_part": {
      "terms": {
        "field": "part",
        "size": 1000
      }
    },
      "aggs": {
    "distinct_manufacturer": {
      "terms": {
        "field": "manufacturer",
        "size": 1000
      }
    }
  }
}

What is the easiest way to sort on manufacturer name?

Try

{
  "aggs": {
    "distinct_part": {
      "terms": {
        "field": "part",
        "size": 1000
      }
    },
    "aggs": {
      "distinct_manufacturer": {
        "terms": {
          "field": "manufacturer",
          "size": 1000,
          "order": {
            "_term": "asc"
          }
        }
      }
    }
  }
}

This is the confusion I have as well, it first sorts on part. Just to let you know my requirement, I want it to first sort on part and then on manufacturer. The order on the manufacturer sub aggregation doesn't seem to be working.

Can you share your mapping and a small sample of the data?

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