# Sub objects vega lite

**URL:** https://discuss.elastic.co/t/sub-objects-vega-lite/133343
**Category:** Kibana
**Created:** [May 25, 2018, 4:11pm UTC](https://discuss.elastic.co/t/sub-objects-vega-lite/133343 "2018-05-25T16:11:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)
#### Post date: [May 25, 2018, 4:11pm UTC](https://discuss.elastic.co/t/sub-objects-vega-lite/133343/1 "2018-05-25T16:11:14Z")

</div>

Actually i am using vega lite plugin in kibana but the problem is when i have the sub objects as result  
i am not able to get the value.

if i want to read the down field value, but i tried '.' operator to reach the path but not able to read is it  
a problem in vega lite not able to read sub objects ? , Please help me on this

sample

> ```
> "aggregations": {
> "2": {
> "buckets": [
> {
> "3": {
> "doc_count_error_upper_bound": 0,
> "sum_other_doc_count": 0,
> "buckets": [
> {
> "1": {
> "hits": {
> "total": 6,
> "max_score": null,
> "hits": [
> {
> "_index": "nosaris",
> "_type": "doc",
> "_id": "2zi_kWMBqA7WTXq2poT_",
> "_score": null,
> "fields": {
> "down": [
> 0
> ]
> },
> "sort": [
> 1521644123000
> ]
> }
> ]
> }
> },
> "4": {
> "hits": {
> "total": 6,
> "max_score": null,
> "hits": [
> {
> "_index": "nosaris",
> "_type": "doc",
> "_id": "2zi_kWMBqA7WTXq2poT_",
> "_score": null,
> "fields": {
> "up": [
> 1
> ]
> },
> "sort": [
> 1521644123000
> ]
> }
> ]
> }
> },
> "key": "VCB STATION QTRS SERTIK",
> "doc_count": 6
> },
> {
> "1": {
> "hits": {
> "total": 6,
> "max_score": null,
> "hits": [
> {
> "_index": "nosaris",
> "_type": "doc",
> "_id": "Bji9kWMBqA7WTXq2MYOo",
> "_score": null,
> "fields": {
> "down": [
> 1
> ]
> },
> "sort": [
> 1521619830000
> ]
> }
> ]
> }
> },
> "4": {
> "hits": {
> "total": 6,
> "max_score": null,
> "hits": [
> {
> "_index": "nosaris",
> "_type": "doc",
> "_id": "Bji9kWMBqA7WTXq2MYOo",
> "_score": null,
> "fields": {
> "up": [
> 0
> ]
> },
> "sort": [
> 1521619830000
> ]
> }
> ]
> }
> },
> "key": "UNITED PAPER BOARD",
> "doc_count": 6
> }
> 
> ```

---

<div class="post-metadata">

### Author: ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)
#### Post date: [May 25, 2018, 5:41pm UTC](https://discuss.elastic.co/t/sub-objects-vega-lite/133343/2 "2018-05-25T17:41:13Z")

</div>

Hi, what does your Vega spec look like?

---

<div class="post-metadata">

### Author: ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)
#### Post date: [May 26, 2018, 1:20am UTC](https://discuss.elastic.co/t/sub-objects-vega-lite/133343/3 "2018-05-26T01:20:06Z")

</div>

Hi this is the way i am reading the path and i also tried different ways like below ,

3.buckets[\*].1.hits.hits[\*].fields.down  
3/.buckets/.1/.hits/.hits/.fields./down  
3//.buckets//.1//.its//.hits//.fields.//down

> {
> 
> $schema: [https://vega.github.io/schema/vega-lite/v2.json](https://vega.github.io/schema/vega-lite/v2.json)  
> title: Event counts from all indexes  
> data: {  
> url: {  
> %context%: true
> 
> ```
> index: nosa
> 
> ```
> 
> body: {  
> "aggs": {  
> "2": {  
> "date\_histogram": {  
> "field": "logdate",  
> "interval": "1d",  
> "time\_zone": "Asia/Shanghai",  
> "min\_doc\_count": 1  
> },  
> "aggs": {  
> "3": {  
> "terms": {  
> "field": "siteaddress.site.keyword",  
> "size": 50,  
> "order": {  
> "\_term": "desc"  
> }  
> },  
> "aggs": {  
> "1": {  
> "top\_hits": {  
> "script\_fields": {  
> "down": {  
> "script": {  
> "inline": "if (doc['status.keyword'].value =='OFF') { return 1 } else { return 0 }",  
> "lang": "painless"  
> }  
> }  
> },  
> "size": 1,  
> "sort": [  
> {  
> "logdate": {  
> "order": "desc"  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> ```
> size: 0
> }
> 
> }
> 
> format: {property: "aggregations.2.buckets"}
> 
> ```
> 
> }
> 
> mark: bar
> 
> encoding: {  
> x: {

```
  field: key
  type: temporal
  axis: {title: false} 
}
y: {
aggregate: sum
field: 3.buckets.1.hits.hits.fields.down
type: quantitative
axis: {title: "Document count"}
}

```

> }  
> }

---

<div class="post-metadata">

### Author: ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)
#### Post date: [June 8, 2018, 5:28pm UTC](https://discuss.elastic.co/t/sub-objects-vega-lite/133343/4 "2018-06-08T17:28:14Z")

</div>

Apologies for the late reply. Check out Yuri's suggestions in this thread:

> [@Kibana vega viz plug-in:multiple aggregations: how-to?](https://discuss.elastic.co/t/kibana-vega-viz-plug-in-multiple-aggregations-how-to/121893/2):
>
> @nielsen-at-cgt Vega-Lite does not have a good built-in handling of nested data results, so I would advise you use [composite aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html). See an example in the video linked from the recent [Vega blog post](https://www.elastic.co/blog/custom-vega-visualizations-in-kibana). If you need to process nested data, you can use full Vega language instead - the ["group" mark](https://vega.github.io/vega/docs/marks/) can be used to draw pre-faceted data.

---

<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: [July 6, 2018, 5:28pm UTC](https://discuss.elastic.co/t/sub-objects-vega-lite/133343/5 "2018-07-06T17:28:20Z")

</div>

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