druid:查询交并非的逻辑
算法类型thetaSketchSetOp:
UNION:取并集
NTERSECT:取交集
NOT:取前后顺序的集合差, 顺序很重要, 顺序不一致导致结果不一致
算法类型thetaSketchEstimate:
pass
{
"aggregations": [
{
"type": "filtered",
"filter": {
"type": "and",
"fields": [
{
"type": "interval",
"dimension": "__time",
"intervals": [
"2019-08-04T16:00:00.000Z/2019-08-05T16:00:00.000Z"
]
},
{
"type": "selector",
"dimension": "event",
"value": "startup"
},
{
"type": "selector",
"dimension": "appkey",
"value": "appyinlizixun"
}
]
},
"aggregator": {
"fieldName": "unique_user", //对以上的条件查询出来的结果的unique_user进行去重计算给active_user
"type": "thetaSketch", //去重函数
"name": "active_user",
"isInputThetaSketch": false,
"size": 16384
}
},
{
"type": "filtered",
"filter": {
"type": "and",
"fields": [
{
"type": "interval",
"dimension": "__time",
"intervals": [
"2019-07-05T16:00:00.000Z/2019-07-06T16:00:00.000Z"
]
},
{
"type": "selector",
"dimension": "event",
"value": "startup"
},
{
"type": "selector",
"dimension": "appkey",
"value": "appyinlizixun"
}
]
},
"aggregator": {
"fieldName": "unique_user",
"type": "thetaSketch",
"name": "new_user",
"isInputThetaSketch": false,
"size": 16384
}
}
],
"intervals": "2019-07-05T16:00:00.000Z/2019-08-05T16:00:00.000Z",
"dataSource": "appyinlizixun-app_statistic",
"granularity": "all",
"threshold": 100000,
"postAggregations": [
{
"field": {
"fields": [
{
"fieldName": "active_user", //上面俩个
"type": "fieldAccess"
},
{
"fieldName": "new_user", //上面两个
"type": "fieldAccess"
}
],
"type": "thetaSketchSetOp",
"func": "NOT"
},
"type": "thetaSketchEstimate",
"name": "user_lost"
},
{
"field": {
"fields": [
{
"fieldName": "active_user",
"type": "fieldAccess"
},
{
"fieldName": "new_user",
"type": "fieldAccess"
}
],
"type": "thetaSketchSetOp",
"func": "INTERSECT"
},
"type": "thetaSketchEstimate",
"name": "user_retain"
}
],
"queryType": "topN",
"dimension": "day",
"metric": "new_user"
}