# How to access data from Elasticsearch in VEGA with nested aggregations

**URL:** <https://discuss.elastic.co/t/how-to-access-data-from-elasticsearch-in-vega-with-nested-aggregations/242871>\
**Category:** Kibana\
**Created:** [July 28, 2020, 9:33am UTC](https://discuss.elastic.co/t/how-to-access-data-from-elasticsearch-in-vega-with-nested-aggregations/242871 "2020-07-28T09:33:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticUser6](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticuser6/32/72899_2.png) [@elasticUser6](https://discuss.elastic.co/u/elasticUser6)\
**Post date:** [July 28, 2020, 9:33am UTC](https://discuss.elastic.co/t/how-to-access-data-from-elasticsearch-in-vega-with-nested-aggregations/242871/1 "2020-07-28T09:33:53Z")

</div>

Hi,

I try to do a, sort of gantt chart, in VEGA. This chart should display on x-axes the time and on y-axes devices been used. So the user can adjust with the time picker and sees all devices been used in this period of time.

When debugging i see that there is the data, but i don´t know how to access it.

![vegadebug](https://us1.discourse-cdn.com/elastic/original/3X/6/3/63782c99238a8feae9dbf4245ac5adc581c04f19.jpeg)

So basically the question is, as shown in the image, I want the key from timebuckets.buckets on the x-axes and the key from timebuckets.buckets.tags.buckets on the y-axes (device names)

```
{

  "$schema": "https://vega.github.io/schema/vega/v4.json",

  "data": {

  "name":"mydata",

    "url": {

      "%context%": true,

      "%timefield%": "time",

      "index": "myIdx",

      "body": {

      "size": 0,

    "aggs" : {

        "time_buckets" : {

           "date_histogram" : {

                "field" : "time",

                "interval" : "1d"

            },

            "aggs": {

                "tags": {

                    "terms": {

                        "field": "deviceName.keyword",

                        "size":10

                    }

                }

            }

        }}

    },

    "format": {"property": "aggregations.time_buckets.buckets"} // is this correct?

  }},

```

So i´m not sure about the "format" and about accessing the key values in a "marks" to draw the chart.  
Do i need the transform for the time? Any help on this would be nice!

Thanks in advance Oliver

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [August 13, 2020, 9:24am UTC](https://discuss.elastic.co/t/how-to-access-data-from-elasticsearch-in-vega-with-nested-aggregations/242871/2 "2020-08-13T09:24:28Z")

</div>

Hi @elasticUser6  
sorry for the late reply, I'd like to check with you if you already solved your issue, if so can you post how so other community member can learn that, if not I can give you some help on that

---

<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:** [September 10, 2020, 9:24am UTC](https://discuss.elastic.co/t/how-to-access-data-from-elasticsearch-in-vega-with-nested-aggregations/242871/3 "2020-09-10T09:24:31Z")

</div>

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