# Nested Aggregation filter seems not working

**URL:** <https://discuss.elastic.co/t/nested-aggregation-filter-seems-not-working/221529>\
**Category:** Elasticsearch\
**Created:** [February 29, 2020, 3:56pm UTC](https://discuss.elastic.co/t/nested-aggregation-filter-seems-not-working/221529 "2020-02-29T15:56:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Indy](https://avatars.discourse-cdn.com/v4/letter/i/e480ec/32.png) [@Indy](https://discuss.elastic.co/u/Indy)\
**Post date:** [February 29, 2020, 3:56pm UTC](https://discuss.elastic.co/t/nested-aggregation-filter-seems-not-working/221529/1 "2020-02-29T15:56:53Z")

</div>

Hello

I try to make a movies / actor / tag aggregation for filter a list of movies.  
For exemple, I want to see all movie's tag for Robert Deni Jr with filter like this : taf (nbMovie)  
ex : action (10) blockbuster (4) romance (2)

If my user filter Robert Deni Jr. movies by a tag (action) filters need to be update. If I check romance then : action (1) blockbuster(2) romance (2)

There is my mapping and query.  
When I perform the query, my aggregation seems to give me a non filter list of tag

Did I do something wrong ? I don't really understand.

```auto
"mapping": {
    "actor": {
      "properties": {
        "id": {
          "type": "keyword"
        },
        "name": {
          "type": "text"
        },
        "videos": {
          "type": "nested",
          "properties": {
            "id": {
              "type": "keyword"
            },
            "studio": {
              "type": "nested",
              "properties": {
                "id": {
                  "type": "keyword"
                },
                "label": {
                  "type": "text"
                }
              }
            },
            "tags": {
              "type": "nested",
              "properties": {
                "id": {
                  "type": "keyword"
                },
                "label": {
                  "type": "text"
                }
              }
            }
          }
        }
      }
    }
  }
}

GET actors/actor/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "match": {
            "id": {
              "query": 587
            }
          }
        },
        {
          "nested": {
            "path": "videos",
            "query": {
              "nested": {
                "path": "videos.tags",
                "query": {
                  "term": {
                    "videos.tags.id": {
                      "value": 2
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "videos": {
      "nested": {
        "path": "videos"
      },
      "aggs": {
        "tags": {
          "nested": {
            "path": "videos.tags"
          },
          "aggs": {
            "tags_id": {
              "terms": {
                "field": "videos.tags.id"
              }
            }
          }
        }
      }
    }
  }
}
```

---

<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 28, 2020, 3:56pm UTC](https://discuss.elastic.co/t/nested-aggregation-filter-seems-not-working/221529/2 "2020-03-28T15:56:53Z")

</div>

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