VEGA GRAPH-通过过滤器获得最高评价

时间:2019-10-23 08:23:02

标签: kibana vega vega-lite

我有这个索引

ST的ID时间
0 1 1 12:04
1 1 12:00
0的2 2的12:02
1 2 2 11:58
0的2 2的11:22
1的3的12:33
0,3,12:20

我正在尝试获取一张图表,该图表可以显示当ST = 0时结果最高的命中(最后一个文档为每个ID弹性索引)

ST的ID时间
0 1 1 12:04
0 2 2 12:02

您可能会看到ID = 3在ST = 1时排名第一,因此它不应出现在表格中

有人可以帮我吗?

BR

2 个答案:

答案 0 :(得分:0)

在Vega-Lite中,可以使用聚合转换,然后使用过滤器转换。例如:

{
  "data": {
    "values": [
      {"ST": 0, "ID": 1, "time": "12:04"},
      {"ST": 1, "ID": 1, "time": "12:00"},
      {"ST": 0, "ID": 2, "time": "12:02"},
      {"ST": 1, "ID": 2, "time": "11:58"},
      {"ST": 0, "ID": 2, "time": "11:22"},
      {"ST": 1, "ID": 3, "time": "12:33"},
      {"ST": 0, "ID": 3, "time": "12:20"}
    ],
    "format": {"parse": {"time": "date:'%H:%M'"}}
  },
  "transform": [
    {
      "aggregate": [
        {"op": "max", "field": "time", "as": "time"},
        {"op": "argmax", "field": "time", "as": "argmax"}
      ],
      "groupby": ["ID"]
    },
    {"filter": "datum.argmax.ST == 0"}
  ],
  "mark": "point",
  "encoding": {
    "y": {"type": "ordinal", "field": "ID"},
    "x": {"type": "temporal", "field": "time"}
  }
}

enter image description here

答案 1 :(得分:0)

<body>  Hi Jakevdp, first thing is nice to meet u! :D

I'm trying to do this in Kibana, with Vega Graph, the problem now is to change this code

"transform": [
    {
      "aggregate": [
        {"op": "max", "field": "time", "as": "time"},
        {"op": "argmax", "field": "time", "as": "argmax"}
      ],
      "groupby": ["ID"]
    },
    {"filter": "datum.argmax.ST == 0"}
  ],

To insert it in Kibana-Vega Graph to attack Elastic, is this possible?
</body>