Hi, this is a duplicated post with this.
As I said, you need to compare each documents with aggregated result by your client side.
As elasticsearch is a distributed system, any supported query or aggregation performed on each shards individualy. The data flows from each data node (containing shards) to the coordinating node one-way. There is no supported query or aggregation which will distribute once aggregated results to each nodes again. This is also the reason why elasticsearch does not support JOIN function of general meaning.