# Aggregation based on Groups of Data

**URL:** <https://discuss.elastic.co/t/aggregation-based-on-groups-of-data/171440>\
**Category:** Elasticsearch\
**Created:** [March 8, 2019, 7:08am UTC](https://discuss.elastic.co/t/aggregation-based-on-groups-of-data/171440 "2019-03-08T07:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkandiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vkandiva/32/42845_2.png) [@vkandiva](https://discuss.elastic.co/u/vkandiva)\
**Post date:** [March 8, 2019, 7:08am UTC](https://discuss.elastic.co/t/aggregation-based-on-groups-of-data/171440/1 "2019-03-08T07:08:07Z")

</div>

Suppose I have a field with values like:

Junior Developer  
Senior Developer  
Database Developer  
Product Manager  
Senior Manager  
Scrum Manager

And say if I have virtual groups based on this data like  
Developer: (Junior Developer,Senior Developer,Database Developer)  
Manager: (Product Manager, Senior Manager, Scrum Manager)

Is it possible to do aggregations which end up in buckets based on these virtual groups of Developer and Manager?

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [March 8, 2019, 9:18am UTC](https://discuss.elastic.co/t/aggregation-based-on-groups-of-data/171440/2 "2019-03-08T09:18:44Z")

</div>

You could use a [filters aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html) for that. You can use that aggregation to create arbitrary buckets of documents that match a set of queries.

You could create one bucket for all documents that match a query for "Junior Developer,Senior Developer,Database Developer" and another buckets for documents that match "Product Manager, Senior Manager, Scrum Manager".

---

<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:** [April 5, 2019, 9:18am UTC](https://discuss.elastic.co/t/aggregation-based-on-groups-of-data/171440/3 "2019-04-05T09:18:49Z")

</div>

Closed on April 5, 2019, 9:18am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
