Sub objects vega lite


(suresh) #1

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
				  }

(Jen Huang) #2

Hi, what does your Vega spec look like?


(suresh) #3

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
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"}
}

}
}


(Jen Huang) #4

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


(system) #5

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