Kibana VEGA - how to build CHART using MULTIPLE buckets aggregations?

匿名 (未验证) 提交于 2019-12-03 01:08:02

问题:

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"           } 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!