The sound filter Aggregator will save you all the requests.
The filtered aggregator combines only the values โโthat correspond to the dimensional filter.
The following query will do the trick in your case: After the druid groups all the events in different countries (since the measurement is a country), the aggregator filter will filter all the events in which it has the id value (e1, e2), and execute the aggregator count on filtered results.
{ ... "dimension":"country", ..., "aggregations": [ { "type" : "filtered", "filter" : { "type" : "selector", "dimension" : "event_id", "value" : ["1","2"] "type": "in" } "aggregator" : { "type" : "count", "name" : "count_countries" } } } ] }
Take the table.
event_id | country | user_id | event_type ================================================ 1 | USA | id1 | visit 2 | USA | id2 | visit 1 | Canada | id3 | visit 3 | USA | id1 | click 1 | Canada | id4 | visit 3 | Canada | id3 | click 3 | USA | id2 | click
The druid will group the results by country.
country | user_id | event_type | event_id ================================================ USA | id1 | visit | 1 USA | id2 | visit | 2 USA | id1 | click | 1 USA | id2 | click | 3 Canada | id3 | visit | 1 Canada | id4 | visit | 3 Canada | id3 | click | 3
The aggregator filter will delete all event_id = 3 due to our filter ("value": ["1", "2"])
country | user_id | event_type | event_id ================================================ USA | id1 | visit | 1 USA | id2 | visit | 2 USA | id1 | click | 1 Canada | id3 | visit | 1
And return the following result (our aggregator is a simple calculation)
country | count
Enjoy it!
source share