# \[ES 7.0\] Filtering nested aggregation - how do I do it?

**URL:** <https://discuss.elastic.co/t/es-7-0-filtering-nested-aggregation-how-do-i-do-it/220851>\
**Category:** Elasticsearch\
**Created:** [February 25, 2020, 12:18pm UTC](https://discuss.elastic.co/t/es-7-0-filtering-nested-aggregation-how-do-i-do-it/220851 "2020-02-25T12:18:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dirkdiggler41](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dirkdiggler41/32/110123_2.png) [@dirkdiggler41](https://discuss.elastic.co/u/dirkdiggler41)\
**Post date:** [February 25, 2020, 12:18pm UTC](https://discuss.elastic.co/t/es-7-0-filtering-nested-aggregation-how-do-i-do-it/220851/1 "2020-02-25T12:18:44Z")

</div>

I have tried to filter out all the objects/documents in the nested objected called jobs\_won, but I can't seem to get it to work. I have been googling for days 😅

**How do I filter out certain objects/documents based on the term "r\_published": 1**

```
{
    "aggs": {
        "jobs_won": {
            "nested": {
                "path": "jobs_won"
            },
            "aggs": {
                "total_jobs_won": {
                    "terms": {
                        "field": "jobs_won.b_id"
                    }
                }
            }
        }
    }
}

```

An example of how a job\_won object/document looks like. This object is nested:

```
{
    "r_score": 5,
    "r_published": 1,
    "b_id": 422133
}
```

---

<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:** [March 24, 2020, 12:24pm UTC](https://discuss.elastic.co/t/es-7-0-filtering-nested-aggregation-how-do-i-do-it/220851/2 "2020-03-24T12:24:19Z")

</div>

Closed on March 24, 2020, 12:24pm UTC

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