# Elastic Search Aggregation with bool query

**URL:** <https://discuss.elastic.co/t/elastic-search-aggregation-with-bool-query/237768>\
**Category:** Elasticsearch\
**Created:** [June 19, 2020, 9:05am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-with-bool-query/237768 "2020-06-19T09:05:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaibhav\_Sharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_sharma/32/64497_2.png) [@Vaibhav\_Sharma](https://discuss.elastic.co/u/Vaibhav_Sharma)\
**Post date:** [June 19, 2020, 9:05am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-with-bool-query/237768/1 "2020-06-19T09:05:31Z")

</div>

This is my elastic bool query. this works fine :

```auto
{
  "query": {
        "bool": {
            "filter": [
                {
                    "terms": {
                        "parent_uuid._raw": [
                            "87ec596a-109e-45ce-8a8d-7a2d1a56df81",
                            "07526608-8140-46be-96b9-c5f7cca4bd93"
                        ]
                    }
                },
                {
                    "terms": {
                        "resource_type._raw": [
                            "Zone"
                        ]
                    }
                }
            ]
        }
    },
    "from": 0
}

```

I want aggregation on name field. So I add this :

```auto
"aggs": {
    "group_by_name": {
        "terms": {
            "field": "display_name.keyword"
        }
    } }

```

But result is same. What I am missing?

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [June 20, 2020, 5:10am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-with-bool-query/237768/2 "2020-06-20T05:10:34Z")

</div>

@Vaibhav_Sharma,  
Can you elaborate "But result is same" ?

If you include query and aggs, you will get 10 results matching your query like basic bool query, but there will be a section in the results for the aggregated value too.

If you only want aggregated value, add "size" : 0 in the query to suppress hits.

---

<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:** [July 18, 2020, 5:10am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-with-bool-query/237768/3 "2020-07-18T05:10:34Z")

</div>

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