This is a Map/Reduce operation, you'll be better off maintaining a ref-count document IMO then trying to hack the aggregations framework to support this
Another reason for doing it that way is in a distributed environment some aggregations can't be computed to an exact value - the Terms bucketing is one example. So if you need exact values, I'd go for a model that does it. -- Itamar Syn-Hershko http://code972.com | @synhershko <https://twitter.com/synhershko> Freelance Developer & Consultant Author of RavenDB in Action <http://manning.com/synhershko/> On Fri, Jun 20, 2014 at 1:34 AM, Mike <[email protected]> wrote: > Assume each document is a book: > { title: "A", author: "Mike" } > { title: "B", author: "Mike" } > { title: "C", author: "Mike" } > { title: "D", author: "Mike" } > > { title: "E", author: "John" } > { title: "F", author: "John" } > { title: "G", author: "John" } > > { title: "H", author: "Joe" } > { title: "I", author: "Joe" } > > { title: "J", author: "Jack" } > > > What is the best way to fin the number of authors who have written between > 2-3 books? In this case it would be 2, John and Joe. > > I know I can do a terms aggregation on author, set size to be very very > large, and then on the client side traverse through the thousands of > authors and count how many had between 2-3. Is there a more efficient way > to do this? The cardinality aggregation is almost what I want, if only I > could specify a min and max term count. > > > -- > You received this message because you are subscribed to the Google Groups > "elasticsearch" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/22fc4e6d-bcac-426c-a343-ff1d36fc25de%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/22fc4e6d-bcac-426c-a343-ff1d36fc25de%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHTr4Zv5%3DmuahwGVbGobX5SgMHYzC_bD4udiZ3XTiAdU1v8YCg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
