# How to aggregate param filtered by nested path?

**URL:** <https://discuss.elastic.co/t/how-to-aggregate-param-filtered-by-nested-path/77211>\
**Category:** Elasticsearch\
**Created:** [March 2, 2017, 7:41pm UTC](https://discuss.elastic.co/t/how-to-aggregate-param-filtered-by-nested-path/77211 "2017-03-02T19:41:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbm-rafal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbm-rafal/32/33539_2.png) [@mbm-rafal](https://discuss.elastic.co/u/mbm-rafal)\
**Post date:** [March 2, 2017, 7:41pm UTC](https://discuss.elastic.co/t/how-to-aggregate-param-filtered-by-nested-path/77211/1 "2017-03-02T19:41:30Z")

</div>

Hi, I want to build aggregation on parameter but filtered by nested path. Something like this:

```
 "aggs": {
      "events.name12": {
     "filter": {},
     "aggs": {
        "events": {
           "nested": {
              "path": "events"
           },
           "aggs": {
              "filtered.events": {
                 "filter": {
                    "terms": {
                       "events.id": [
                          448,
                          435,
                          338,
                          364
                       ]
                    }
                 },
                 "aggs": {
                    "filtered": {
                       "filter": {},
                       "aggs": {
                          "profile.email": {
                             "terms": {
                                "field": "email",
                                "size": 5
                             }
                          },
                          "profile.email_name": {
                             "cardinality": {
                                "field": "email"
                             }
                          }
                       }
                    }
                 }
              }
           }
        }
     }
  }
  },

```

is this possible ?

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [March 3, 2017, 1:10pm UTC](https://discuss.elastic.co/t/how-to-aggregate-param-filtered-by-nested-path/77211/2 "2017-03-03T13:10:59Z")

</div>

Can you provide a minimal example? I don't understand your question.

---

<div class="post-metadata">

**Author:** ![mbm-rafal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbm-rafal/32/33539_2.png) [@mbm-rafal](https://discuss.elastic.co/u/mbm-rafal)\
**Post date:** [March 3, 2017, 1:29pm UTC](https://discuss.elastic.co/t/how-to-aggregate-param-filtered-by-nested-path/77211/3 "2017-03-03T13:29:27Z")

</div>

I'm building aggregation on nested path, but at the bottom level is field "email" which is not at defined path for aggregator. I want to build aggregate of "email" where [events.id](http://events.id) are as provided (nested mapping)

---

<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 31, 2017, 1:29pm UTC](https://discuss.elastic.co/t/how-to-aggregate-param-filtered-by-nested-path/77211/4 "2017-03-31T13:29:33Z")

</div>

Closed on March 31, 2017, 1:29pm UTC

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