Thank you for your answer!
The main problem is that the fields to aggregate and sort are unknown in advance. So using ingest pipeline will require me to insert all possible combinations. Same for index sorting - Since I don't know what fields will be used for aggregating and sorting I cant use this method.
Any other idea maybe?
Thank you