# Aggregation bucket in Vega returns an object not a bucket

**URL:** <https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [November 18, 2020, 9:53pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906 "2020-11-18T21:53:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maria20](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maria20/32/45638_2.png) [@Maria20](https://discuss.elastic.co/u/Maria20)\
**Post date:** [November 18, 2020, 9:53pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906/1 "2020-11-18T21:53:59Z")

</div>

Hi,  
I am following a tutorial on Vega visualization on Kibana. The tutorial is similar to draw a graph of bars using aggregation. I followed the steps mentioned in [this thread](https://discuss.elastic.co/t/how-can-i-visualize-aggregation-buckets-using-vega-not-vega-lite/194336/3). However, my graph is not displayed, when I debugged the response I noticed that the format does not return the bucket, instead, it returns an object as in the image.

```auto
   "body": {
            // "size" : 0,
            "aggs": {
                "authors":{
                  "terms":{"field": "authorId.keyword","size":10 }
               }
            }
        }
           "format": {
            property: "aggregations.authors.buckets"
            
          }   

```

 ![Screenshot 2020-11-18 at 21.48.57](https://us1.discourse-cdn.com/elastic/original/3X/6/5/65fc3224f142a47beb87baa63dc0e5d598ad1e73.png)

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 19, 2020, 4:02pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906/2 "2020-11-19T16:02:36Z")

</div>

I'm not sure your formatting is being applied correctly, it looks like it might be in the wrong place in the hierarchy. You can read the improved [Vega-Lite tutorial](https://www.elastic.co/guide/en/kibana/current/vega-lite-tutorial-create-your-first-visualizations.html) and Vega tutorial to see some examples. Also, in 7.10 there is now an Inspector feature for Vega.

---

<div class="post-metadata">

**Author:** ![Maria20](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maria20/32/45638_2.png) [@Maria20](https://discuss.elastic.co/u/Maria20)\
**Post date:** [November 19, 2020, 4:28pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906/3 "2020-11-19T16:28:44Z")

</div>

Thank you for your reply. I checked the tutorials. I am using vega not vega-like as the forced graph I am using is not avlaliale in vega-lite. My data format as follows

```auto
{"authorId": "X", "title": "X", "paperCount": 8}
{"authorId": "X2", "title": "X2", "paperCount": 7}

```

When I do search in the dev tools for the same equivalent query to the one in the vega above. I got the following:  
guery

```auto
GET author-terms_elk/_search 
{
  "size": 10,
  "aggs": {
    "authors" :{
      "terms": {
        "field": "authorId.keyword",
        "size": 10
      }
    }
  }
}

```

response

```auto
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 416,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "inx",
        "_type" : "doc",
        "_id" : "0",
        "_source" : {
          "authorId" : "x",
          "title" : "xx",
        }
      },
      { ..}]

```

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 19, 2020, 4:45pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906/4 "2020-11-19T16:45:30Z")

</div>

That was not exactly what I was asking. I think your Vega spec is not set up right, specifically the `format` section of your Vega spec. Please try to match the tutorial.

---

<div class="post-metadata">

**Author:** ![Maria20](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maria20/32/45638_2.png) [@Maria20](https://discuss.elastic.co/u/Maria20)\
**Post date:** [November 20, 2020, 12:01pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906/5 "2020-11-20T12:01:33Z")

</div>

Thanks. Yes, I sorted the format section and it works. The solution is

```auto
            property: "dataName.aggName.buckets"

```

---

<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 18, 2020, 12:01pm UTC](https://discuss.elastic.co/t/aggregation-bucket-in-vega-returns-an-object-not-a-bucket/255906/6 "2020-12-18T12:01:34Z")

</div>

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