德鲁伊查询计数多列

时间:2019-06-25 10:43:04

标签: nosql druid

我有一个查询要计算一列中的空值。如何调整它以返回多个列中的空值计数?我尝试添加字段列表,例如['ip_address','user_agent']转到维度字段,但这无效。

{"intervals":["2019-05-26T00:00:00.000Z/2019-06-25T00:00:00.000Z"],
"granularity":"all",
"context":{"timeout":60000,
"queryId":"71fe66b2-e654-45dc-8a8c-38ed160e79f5"},
"queryType":"timeseries",
"dataSource":"dataset-tablename”,
"aggregations":[{"type":"count",
"name":"count"}],
"filter":{"type":"and",
"fields":[{"type":"selector",
"dimension":"ip_address",
"value":"null"}]}}

这将返回两列,

  

时间戳记|计数

     

2019-04-27T04:55:01.000Z | 246,933

是在时间范围内具有空值的ip_address记录的计数。如何返回其他附加字段的计数?

1 个答案:

答案 0 :(得分:1)

您可以使用过滤的聚合器:

{"intervals":["2019-05-26T00:00:00.000Z/2019-06-25T00:00:00.000Z"],
"granularity":"all",
"context":{"timeout":60000, "queryId":"71fe66b2-e654-45dc-8a8c-38ed160e79f5"},
"queryType":"timeseries",
"dataSource":"dataset-tablename",
 "aggregations":[
     {"type":"filtered", "filter":{"type":"selector", "dimension":"ip_address", "value":"null"},
      "aggregator": {"type":"count", "name":"null_ip_address_count"}},
     {"type":"filtered", "filter":{"type":"selector", "dimension":"user_agent", "value":"null"},
      "aggregator": {"type":"count", "name":"null_user_agent_count"}}]
}

也就是说,不要将过滤器应用于整个查询,而是将过滤器应用于单个聚合器。