Conditionally run aggregation

I'm wondering if there's any way to run aggregation conditionally.
So I have a _search request that have both query and aggs param. So the aggs is scoped by the query param.

Now if the query return no hits, is there a way to skip the aggregation completely?

Thanks

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