# Empty buckets for filtered nested aggregation in 5.0 version

**URL:** <https://discuss.elastic.co/t/empty-buckets-for-filtered-nested-aggregation-in-5-0-version/66351>\
**Category:** Elasticsearch\
**Created:** [November 17, 2016, 9:02am UTC](https://discuss.elastic.co/t/empty-buckets-for-filtered-nested-aggregation-in-5-0-version/66351 "2016-11-17T09:02:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ithilmar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ithilmar/32/13231_2.png) [@ithilmar](https://discuss.elastic.co/u/ithilmar)\
**Post date:** [November 17, 2016, 9:02am UTC](https://discuss.elastic.co/t/empty-buckets-for-filtered-nested-aggregation-in-5-0-version/66351/1 "2016-11-17T09:02:24Z")

</div>

Hello!  
I have some problem with filtered nested terms bucket aggregation.

Mappings data for 'region' field:

```
{
        'type': 'nested',
        'properties': {
              'country': {'type': 'keyword'},
              'province': {'type': 'keyword'},
              'district': {'type': 'keyword'},
              'city': {'type': 'keyword'}
        }
}

```

Each document may have some values of "region", i.e. it is array of nested type.  
I need to do bucket terms aggregation e.g for "region.city" field with using filter aggregation by some "region.province" value. So, my aggregation section looks like:

```
{
    'region': {
        'nested': {
            'path': 'region'
        },
        'aggs': {
            'region-filter': {
                'filter':
                    {'term': {'region.province': value}}
                ,
                'aggs': {
                    'city': {
                        'terms': {
                            'field': 'region.city',
                        },
                    }
                }
            }
        }
    }
}

```

But in returned result my city-buckets are always empty. Is it some bug or there is something wrong in my aggregation section?

---

<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:** [December 15, 2016, 9:03am UTC](https://discuss.elastic.co/t/empty-buckets-for-filtered-nested-aggregation-in-5-0-version/66351/2 "2016-12-15T09:03:12Z")

</div>

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