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 my Index Mappings
{
"orderindex": {
"aliases": {},
"mappings": {
"orderbook": {
"properties": {
"exchange": {
"type": "keyword"
},
"id": {
"type": "integer"
},
"label": {
"type": "keyword"
},
"length": {
"type": "integer"
},
"orders": {
"type": "nested",
"properties": {
"exchange": {
"type": "keyword"
},
"id": {
"type": "integer"
},
"label": {
"type": "keyword"
},
"orderbookId": {
"type": "integer"
},
"ordertype": {
"type": "keyword"
},
"pair1": {
"type": "keyword"
},
"pair2": {
"type": "keyword"
},
"price": {
"type": "double"
},
"quantity": {
"type": "double"
},
"timestamp": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"total": {
"type": "double"
}
}
},
"timestamp": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1526318629953",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "7AeKJAdlQzSPf9WajEUlxA",
"version": {
"created": "6020499"
},
"provided_name": "orderindex"
}
}
}
}
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}
}
}
}
My intention with this query is to result in something similar to the multi view graphs draft picture below based on Vega web site multi view graph example for Kibana
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"
}