Trying to get the count of products from my json index (eg. test-index). Aggregation output from dev tool is mentioned below.
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 762,
"relation" : "eq"
},
"max_score" : null,
"hits" :
},
"aggregations" : {
"types_count" : {
"value" : 760
}
}
}
#########Vega Code used
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"data": [
{
"name": "table",
url: {
%context%: true
"index": "test-index",
"body": {
"size": 0,
"aggs": {
"types_count" : { "value_count" : { "field" : "project.keyword" } }
}
}
}
},
{
"name": "table-flattened",
"source": "table",
"transform": [
{
"type": "formula",
"as": "project",
"expr": "datum.aggregations.types_count"
},
{"type": "identifier", "as": "boxposition"}
]
}
],
"marks": [
{
"type": "rect",
"from": {"data": "table-flattened"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "boxposition"},
"y": {"value": 5},
"width": {"value": 100},
"height": {"value": 55},
"cornerRadius": {"value": 14},
"border": {"value": 0},
}
}
},
{
"type": "text",
"from": {"data": "table-flattened"},
"encode": {
"enter": {
"text": {"field": "project"},
"x": {"scale": "x", "field": "boxposition", "offset": 55},
"y": {"value": 40},
"align": {"value": "left"},
"fontSize": {"value": 14},
"fill": { "value": "white" }
}
}
},
{
"type": "text",
"from": {"data": "table-flattened"},
"encode": {
"enter": {
"text": {"value": "Projects#"},
"x": {"scale": "x", "field": "boxposition", "offset": 50},
"y": {"value": 40},
"align": {"value": "right"},
"fontSize": {"value": 14},
"fill": { "value": "white" }
}
}
}
]
}