Facet (or any sort of count) on number of children

Hi,

We have this setup where we have a parent and child documents. Each parent
may have multiple children, and I'm interested to find the top X parents,
by the number of children (which would be filtered in some way).

For example, let's assume that we have authors as the parent type, and
books as another type, where each book has an author as its parent.

How can I find the top 10 authors by the number of books they wrote on a
specific genre?

I'm not looking specifically for facets here, although they seem to be the
natural approach. Maybe script based sorting would also be an option? If
so, how can I count the children in a such a script?

Best regards,
Radu