I'd appreciate suggestions for modeling a simple author-books relation for a particular sorting use case (using elasticsearch 2.0)
I want to retrieve a list of all books (together with author details), grouped by author.
The list shall be ordered descending by the number of books an author has written.
So the busiest author's books come up on top and books by authors who have only
written one book come last.
I want to be able to filter this list by attributes of both author and book.
I had some success modelling this as two types with a parent-child relation
and a has_parent filter. This thing that escapes me is how to do the sorting
based on the cardinality of the child (book).
Will I have to resort to full denormalization, like including all author fields in the book rows?
I'd prefer to do this in one query, although I'm aware that with the current limitation this may not be achievable. Can one aggregate on inner_hits and sort upon that? I couldn't figure out, how...
I'm aware that I may be asking a bit too much as ES is not a relational database. I'd still would make my life much easier.
Any suggestion appreciated.