# Nesting the Aggregation Filter in Logstash

**URL:** <https://discuss.elastic.co/t/nesting-the-aggregation-filter-in-logstash/105784>\
**Category:** Elasticsearch\
**Created:** [October 30, 2017, 4:56pm UTC](https://discuss.elastic.co/t/nesting-the-aggregation-filter-in-logstash/105784 "2017-10-30T16:56:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohinirajaram](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@rohinirajaram](https://discuss.elastic.co/u/rohinirajaram)\
**Post date:** [October 30, 2017, 4:56pm UTC](https://discuss.elastic.co/t/nesting-the-aggregation-filter-in-logstash/105784/1 "2017-10-30T16:56:50Z")

</div>

I am looking at nesting aggregations for a document which contains a list for a column type which in turn contains a list. Consider the scenario provided on the aggregate filter page

[https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html)

A typical case is aggregating results from jdbc input plugin.  
Given that you have this SQL query : SELECT country\_name, town\_name FROM town  
Using jdbc input plugin, you get these 3 events from :  
{ "country\_name": "France", "town\_name": "Paris" }  
{ "country\_name": "France", "town\_name": "Marseille" }  
{ "country\_name": "USA", "town\_name": "New-York" }

In the above case, if I were to introduce a "state\_name", how can I aggregate first by country\_name followed by state\_name and then all town\_names into an ElasticSearch document?

---

<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:** [November 27, 2017, 4:57pm UTC](https://discuss.elastic.co/t/nesting-the-aggregation-filter-in-logstash/105784/2 "2017-11-27T16:57:27Z")

</div>

Closed on November 27, 2017, 4:57pm UTC

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