You would have to specify in the query that the size is equal to 0
ex :
{
"query": ... ,
"aggs": ... ,
"size": 0
}
Related doc page on ES website: https://www.elastic.co/guide/en/elasticsearch/reference/current/returning-only-agg-results.html