# Plotting the result of nested aggregations in kibana

**URL:** <https://discuss.elastic.co/t/plotting-the-result-of-nested-aggregations-in-kibana/290074>\
**Category:** Kibana\
**Created:** [November 24, 2021, 1:42pm UTC](https://discuss.elastic.co/t/plotting-the-result-of-nested-aggregations-in-kibana/290074 "2021-11-24T13:42:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![M.KRISHNAKANT\_ACHARY](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.krishnakant_achary/32/97524_2.png) [@M.KRISHNAKANT\_ACHARY](https://discuss.elastic.co/u/M.KRISHNAKANT_ACHARY)\
**Post date:** [November 24, 2021, 1:42pm UTC](https://discuss.elastic.co/t/plotting-the-result-of-nested-aggregations-in-kibana/290074/1 "2021-11-24T13:42:57Z")

</div>

I have an index which has nested data types.  
when I am running this query

```auto
{
  "size":0,
  "aggs": {
    "tenant": {
      "nested": {
        "path": "custom_details.tenantname"
      },
      "aggs": {
        "count1": {
          "terms": {
            "field": "custom_details.tenantname.value.keyword"
          }
        }
      }
    }
  }
}

```

I am getting the aggregation results as this:

```auto
{
  "took" : 9,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 6,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "aggregations" : {
    "tenant" : {
      "doc_count" : 18,
      "count1" : {
        "doc_count_error_upper_bound" : 0,
        "sum_other_doc_count" : 0,
        "buckets" : [
          {
            "key" : "fis",
            "doc_count" : 3
          },
          {
            "key" : "abc",
            "doc_count" : 2
          },
          {
            "key" : "mno",
            "doc_count" : 2
          },
          {
            "key" : "123",
            "doc_count" : 2
          },
          {
            "key" : "btw",
            "doc_count" : 2
          },
          {
            "key" : "iqr",
            "doc_count" : 2
          },
          {
            "key" : "rms",
            "doc_count" : 2
          },
          {
            "key" : "pqr",
            "doc_count" : 1
          },
          {
            "key" : "xyz",
            "doc_count" : 1
          },
          {
            "key" : "acb",
            "doc_count" : 1
          }
        ]
      }
    }
  }
}

```

I would like to plot these aggregated results as a pie chart in kibana. But I am unable to select the `custom_details.tenantname.value.keyword` field as it is a nested type field.

I am new to Elasticsearch and kibana. Any help in plotting the aggregation result will be very helpful.  
PS: Is there a way to give the query and get plot as output?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [November 24, 2021, 3:11pm UTC](https://discuss.elastic.co/t/plotting-the-result-of-nested-aggregations-in-kibana/290074/2 "2021-11-24T15:11:15Z")

</div>

Unfortunately it's not possible to use the pie chart for this - but you should be able to get it to work using vega: [Vega | Kibana Guide [7.15] | Elastic](https://www.elastic.co/guide/en/kibana/current/vega.html)

It basically allows you to use your existing query, then define a vega spec to render the chart. This is an example of a pie chart in vega, you should be able to combine it with your query: [Pie chart in vega](https://discuss.elastic.co/t/pie-chart-in-vega/260373)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 22, 2021, 3:11pm UTC](https://discuss.elastic.co/t/plotting-the-result-of-nested-aggregations-in-kibana/290074/3 "2021-12-22T15:11:34Z")

</div>

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