How to get documents in Elasticsearch based on aggregation output values?

You can't at the moment sorry! :frowning:
You will need to run the agg to get the average, then run a separate query to get the docs that match the values.