Aggregations happen as part of the search phase (not any subsequent "fetch" phase) so all data gathering is done in isolation of what might be happening on other remote shards - eg finding some global max for a field.
To do what you want you'd need two search phases so this is something you'd have to do in your client as 2 separate requests:
@Mark_Harwood Yes currently I am following the 2 search request pattern but just to optimise it wanted to know if there is any other way to do so but as you have explained now it won't be the case.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.