I can't figure out how to deal with 2 buckets to draw a multi-view graph in Vega for Kibana.
My index in Kibana contains orderbooks that aggregates orders per label bucket (e.g: USD/CAD).
How do I build a VEGA chart in Kibana that works with 2 buckets?
This is how I try to use Vega to draw multi-view graphs
Vega query
{ "$schema": "https://vega.github.io/schema/vega-lite/v2.json", "title": "Order Totals vs Order Ids", "data": { "url": { "index": "orderindex", "body": { "size": 0, "_source": { "excludes": [] }, "aggs": { "order_labels": { "terms": { "field": "label", "size": 12, "order": { "_count": "desc" } }, "aggs": { "orders": { "nested": { "path": "orders" }, "aggs": { "orders_id": { "terms": { "field": "orders.id", "size": 40, "order": { "_count": "desc" } }, "aggs": { "orders_price": { "sum": { "field": "orders.price" } } } } } } } } }, "stored_fields": ["*"], "script_fields": {}, "docvalue_fields": [], "query": { "bool": { "must": [ { "match_all": {} } ], "filter": [], "should": [], "must_not": [] } } } }, "format": { "property": "aggregations.order_labels.buckets.orders.orders_id.buckets.orders_price" } }, "mark": "bar", "encoding": { "row": { "field": "order_labels", "type": "ordinal" }, "x": { "field": "orders_price.value", "type": "quantitative", "scale": {"zero": false} }, "y": { "field": "orders_id", "type": "ordinal", "sort": {"field": "orders_price.value","op": "sum", "order": "descending"}, "scale": {"rangeStep": 40} } } }
The aim is to display the sum of orders' price per bucket label as in the sample picture above.
The problem is that I am receiving an error from the vega query above that says Cannot read property 'orders_id' of undefined
. I believe this is because I have multiple buckets aggregation in my query response and I don`t know how to deal with this.
How should I format my property here below in this part of Vega Query to make it work? Or, what should I do to get this 2 buckets multi aggregation query to work with multi-view charts in Vega?
"format": { "property": "aggregations.order_labels.buckets.orders.orders_id.buckets.orders_price" }