I have ~5 million documents that are in categories and subcategories. Let us say that my query is for search terms in one top-level category and it returns a large amount of documents and I want to list the top 5 sub-categories by highest count total. I know I can't go one by one counting through the results because it is too slow.
I really don't care about the counts, I just want the sub-categories with the most documents in them. Options that I was thinking about: 1) Do queries for each sub-category using the results of the first initial query and use the hits count to select the sub-categories to display, but I might have thousands of sub-categories and it would be too slow.. 2) Just select some sub-categories for each top-level category to always show, but this is bad because that sub-category might not have items found in it after the initial query. 3) Give-Up, but this is bad also.. Thanks for your help.