# How can I use Aggregation by result by match\_phase?

**URL:** <https://discuss.elastic.co/t/how-can-i-use-aggregation-by-result-by-match-phase/92748>\
**Category:** Elasticsearch\
**Created:** [July 12, 2017, 2:52am UTC](https://discuss.elastic.co/t/how-can-i-use-aggregation-by-result-by-match-phase/92748 "2017-07-12T02:52:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kieaiaarh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kieaiaarh/32/12363_2.png) [@kieaiaarh](https://discuss.elastic.co/u/kieaiaarh)\
**Post date:** [July 12, 2017, 2:52am UTC](https://discuss.elastic.co/t/how-can-i-use-aggregation-by-result-by-match-phase/92748/1 "2017-07-12T02:52:54Z")

</div>

# Enviroment

ES 5.2

sample is not working

```auto
{
  "from": 0,
  "size": 0,
  "aggs": {
    "image_tag" : {
      "children": {
        "type": "review"
      },
      "aggs": {
        "image_tags" : {
            "filter": {"query": {"match_phrase": {
              "user_comment": "hogehoge"
            }}} 
        }
      }
    }
  }
}

```

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "Could not find aggregator type [query] in [image_tags]",
        "line": 11,
        "col": 22
      }
    ],
    "type": "parsing_exception",
    "reason": "Could not find aggregator type [query] in [image_tags]",
    "line": 11,
    "col": 22
  },
  "status": 400
}

```

---

<div class="post-metadata">

**Author:** ![timost](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@timost](https://discuss.elastic.co/u/timost)\
**Post date:** [July 12, 2017, 7:59am UTC](https://discuss.elastic.co/t/how-can-i-use-aggregation-by-result-by-match-phase/92748/2 "2017-07-12T07:59:36Z")

</div>

Hi ! Looking at [the doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html) I think the `query` field should not be present. Can you try:

```auto
{
  "from": 0,
  "size": 0,
  "aggs": {
    "image_tag" : {
      "children": {
        "type": "review"
      },
      "aggs": {
        "image_tags" : {
            "filter": {
              "match_phrase": {
                "user_comment": "hogehoge"
            }
          }
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![kieaiaarh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kieaiaarh/32/12363_2.png) [@kieaiaarh](https://discuss.elastic.co/u/kieaiaarh)\
**Post date:** [July 12, 2017, 9:02am UTC](https://discuss.elastic.co/t/how-can-i-use-aggregation-by-result-by-match-phase/92748/3 "2017-07-12T09:02:23Z")

</div>

Oups! Thanks for help me.  
It work!

---

<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:** [August 9, 2017, 9:02am UTC](https://discuss.elastic.co/t/how-can-i-use-aggregation-by-result-by-match-phase/92748/4 "2017-08-09T09:02:26Z")

</div>

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