What's a good strategy for getting one or as many document per group depending on the group

Top hits doc is: Top hits aggregation | Elasticsearch Guide [8.11] | Elastic

If you can't make it work, could you provide a full recreation script as described in

It will help to better understand what you are doing.
Please, try to keep the example as simple as possible.