I need to query some properties of "rooms" documents that each belongs to a "Hotel". And finally I want to display the "hotels" paginated.
The problem is that if I index the "rooms" then the pagination (using "size" and "from") will get multiple rooms that belong to the same hotel so instead of, let's say, 10 hotels in a page, I end up with 7 of them.
If I index the "hotels" and place the "rooms" as nested documents. Then I get the desired result, paginated "hotel" documents, but I don't know exactly which of the "rooms" in each "hotel" made the hit. And also, I cannot sort the "hotels" based on the "rooms" that made the hit.
If I index the "rooms" and aggregate buckets by term "hotel.id", then I get all that I need but I cannot paginate the results, since buckets do not support paginations. And I need up with huge results that I cannot work with.
Can anyone point me in the right direction?