# GROUP BY in Elasticsearch using 'aggs' is not working for me in PHP

**URL:** <https://discuss.elastic.co/t/group-by-in-elasticsearch-using-aggs-is-not-working-for-me-in-php/187495>\
**Category:** Elasticsearch\
**Created:** [June 26, 2019, 7:06am UTC](https://discuss.elastic.co/t/group-by-in-elasticsearch-using-aggs-is-not-working-for-me-in-php/187495 "2019-06-26T07:06:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShashankAC](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@ShashankAC](https://discuss.elastic.co/u/ShashankAC)\
**Post date:** [June 26, 2019, 7:06am UTC](https://discuss.elastic.co/t/group-by-in-elasticsearch-using-aggs-is-not-working-for-me-in-php/187495/1 "2019-06-26T07:06:01Z")

</div>

I have an elasticsearch query in PHP like this.

> $params = [  
> 'index' =\> $table\_name,  
> 'type' =\> '\_doc',  
> 'size' =\> 4894,  
> 'body' =\> [  
> 'query' =\> [  
> 'aggs' =\> [  
> 'some\_key' =\> [  
> 'bool' =\> [  
> 'filter' =\> [  
> ['terms' =\> ['key1' =\> $array1]],  
> ['terms' =\> ['key2' =\> $array2]],  
> ['terms' =\> ['key3' =\> $array3]],  
> ['terms' =\> ['key4' =\> $array4]]  
> ]  
> ]  
> ]  
> ]  
> ]  
> ]  
> ];

I am able to get the 'filter' working properly without using any aggregation, but I need the result of the filter to be aggregated with respect to the 'some\_key' but I am getting an error like below.

> {"error":{"root\_cause":[{"type":"parsing\_exception","reason":"no [query] registered for [aggs]","line":1,"col":18}]

Please help me out.

---

<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 24, 2019, 7:06am UTC](https://discuss.elastic.co/t/group-by-in-elasticsearch-using-aggs-is-not-working-for-me-in-php/187495/2 "2019-07-24T07:06:05Z")

</div>

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