Add aggregations

I'm creating again a PR adding aggregations used to filter queries.