# Aggregations to get counts of different query?

**URL:** <https://discuss.elastic.co/t/aggregations-to-get-counts-of-different-query/24291>\
**Category:** Elasticsearch\
**Created:** [June 24, 2015, 7:16pm UTC](https://discuss.elastic.co/t/aggregations-to-get-counts-of-different-query/24291 "2015-06-24T19:16:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaddison](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jaddison](https://discuss.elastic.co/u/jaddison)\
**Post date:** [June 24, 2015, 7:16pm UTC](https://discuss.elastic.co/t/aggregations-to-get-counts-of-different-query/24291/1 "2015-06-24T19:16:12Z")

</div>

I'm simplifying here, but bear with me. I have two document types: Business and Activity. Activities are owned by Businesses, meaning that an Activity simply has a 'business\_id' field. There's no nesting or parent/child mappings here - they are separate document types.

I'd like to get a list of Businesses, each with a count of Activities matching a query - for example, only Activities that start greater than or equal to today. I think this should be possible with Aggregations, but I can't quite figure it out.

Any guidance?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:05am UTC](https://discuss.elastic.co/t/aggregations-to-get-counts-of-different-query/24291/2 "2017-07-06T00:05:32Z")

</div>

Closed on July 6, 2017, 12:05am UTC


