Median of the result of top_hits

Hi!

I have top_hits aggregation and I want to calculate median from it, but ES says:
Aggregator [hits] of type [top_hits] cannot accept sub-aggregations

Maybe there are some other ways of doing such things?
My data looks like this:
{
"key": "string",
"creation_date": "date",
"metric":"number"
}

And I want to aggregate them by key, take top 3 hits by creation_date and calculate median of "metric" field.

Thanks!