How to get docs in aggregated format in ElasticSearch aggregation query?

My query

{
  "aggs": {
    "distinct_colours": {
      "terms": {
        "field": "colour"
      }
    }
  }
}

Required Result:

{
  "took" : 2037,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "distinct_colours" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 34,
      "buckets" : [
        {
          "key" : "BLACK",
          "docs" : [{
            "id": "block_doc_key",
            "avialability": true
          }]
        },
        {
          "key" : "GREEN",
          "doc" : [{
            "id": "green_doc_key",
            "avialability": false
          }]
        }
      ]
    }
  }
}

Can I get the result docs corresponding to each bucket as I have mentioned above (in "Required Result")? I am not able to find the correct query for this. please help.

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