To use this aggregator, make sure you the extension in your config file:
{
"type" : "thetaSketch",
"name" : <output_name>,
"fieldName" : <metric_name>,
"isInputThetaSketch": false,
"size": 16384
}
Sketch Estimator
{
"type" : "thetaSketchEstimate",
"name": <output name>,
"field" : <post aggregator of type fieldAccess that refers to a thetaSketch aggregator or that of type thetaSketchSetOp>
}
Sketch Operations
Sketch Summary
This returns a summary of the sketch that can be used for debugging. This is the result of calling toString() method.
{
"type" : "thetaSketchToString",
"name": <output name>,
"field" : <post aggregator that refers to a Theta sketch (fieldAccess or another post aggregator)>
}
Assuming, you have a dataset containing (timestamp, product, user_id). You want to answer questions like
to answer above questions, you would index your data using following aggregator.
{ "type": "thetaSketch", "name": "user_id_sketch", "fieldName": "user_id" }
then, sample query for, How many unique users visited product A?
sample query for, How many unique users visited both product A and B?
{
"queryType": "groupBy",
"dataSource": "test_datasource",
"granularity": "ALL",
"filter": {
"type": "or",
"fields": [
{"type": "selector", "dimension": "product", "value": "B"}
]
},
"aggregations": [
{
"type" : "filtered",
"filter" : {
"type" : "selector",
"dimension" : "product",
"value" : "A"
},
"aggregator" : {
"type": "thetaSketch", "name": "A_unique_users", "fieldName": "user_id_sketch"
}
},
{
"type" : "filtered",
"filter" : {
"type" : "selector",
"dimension" : "product",
"value" : "B"
},
"aggregator" : {
"type": "thetaSketch", "name": "B_unique_users", "fieldName": "user_id_sketch"
}
"postAggregations": [
{
"type": "thetaSketchEstimate",
"name": "final_unique_users",
"field":
{
"type": "thetaSketchSetOp",
"name": "final_unique_users_sketch",
"func": "INTERSECT",
"fields": [
{
"type": "fieldAccess",
"fieldName": "A_unique_users"
},
{
"type": "fieldAccess",
"fieldName": "B_unique_users"
}
]
}
}
],
"intervals": [
"2014-10-19T00:00:00.000Z/2014-10-22T00:00:00.000Z"
]
}
Retention Analysis Example
e.g., “How many unique users signed up in week 1, and purchased something in week 2?”
Using the example dataset, data would be indexed with the following aggregator, like in the example above:
The following query expresses: