Mike
(Mike)
August 24, 2012, 5:48pm
1
Assume I have a couple books like this:
{ title:"One", author: "John" }
{ title:"Two", author: "John" }
{ title:"Three", author: "Alex" }
{ title:"Four", author: "Alex" }
{ title:"Five", author: "Mike" }
{ title:"Six", author: "Mike" }
{ title:"Seven", author: "Mike" }
{ title:"Eight", author: "Dave" }
How can I get a grouping of authors by the number of books they wrote?
I can make a terms facet on author to get the top 4 most published authors
and get:
Mike : 3
John : 2
Alex : 2
Dave : 1
But what if I want something like this:
Written 6+ books : 0
Written 2-5 books : 3
Written 1 book : 1
--
Nick_Dunn
(Nick Dunn)
August 25, 2012, 6:20am
2
As far as I know "group by" isn't supported. I think you'd need to convert your facet result to your desired range output in your own application logic.
--
dadoonet
(David Pilato)
August 26, 2012, 3:15pm
4
IMHO you are doing a count on Authors (books per author). You have to index Authors (and their books if needed).
Then, you can apply a RangeFacet on Authors.
My 2 cents.
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 24 août 2012 à 19:48, Mike mnilsson2323@gmail.com a écrit :
Assume I have a couple books like this:
{ title:"One", author: "John" }
{ title:"Two", author: "John" }
{ title:"Three", author: "Alex" }
{ title:"Four", author: "Alex" }
{ title:"Five", author: "Mike" }
{ title:"Six", author: "Mike" }
{ title:"Seven", author: "Mike" }
{ title:"Eight", author: "Dave" }
How can I get a grouping of authors by the number of books they wrote?
I can make a terms facet on author to get the top 4 most published authors and get:
Mike : 3
John : 2
Alex : 2
Dave : 1
But what if I want something like this:
Written 6+ books : 0
Written 2-5 books : 3
Written 1 book : 1
--
--