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

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.

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