You should first run the query on the parent domain ( give me all the books
or a limited set of them).
Then you should do the faceting on the children domain.

>From Yonik blog :
"
$ curl http://localhost:8983/solr/demo/query -d '
q=cat_s:(sci-fi OR fantasy)&fl=id,title_t&
json.facet={
  top_reviewers : {
    type: terms,
    field: author_s,
    domain: { blockChildren : "type_s:book" }
  }
}'

Response:
"response":{"numFound":2,"start":0,"docs":[
    {
      "id":"book1",
      "title_t":["The Way of Kings"]},
    {
      "id":"book2",
      "title_t":["Snow Crash"]}]
},
"facets":{
  "count":2,
  "top_reviewers":{
    "buckets":[{
        "val":"dan",
        "count":2},
      {
        "val":"yonik",
        "count":2},
      {
        "val":"mary",
        "count":1}]
}}"

Cheers

2015-08-05 3:10 GMT+01:00 dxxd116 <caixingli...@gmail.com>:

> If I want to do a faceting on field in child document and the get the count
> of parent document, how should I construct my query?
>
> E.g, I want to find out the authors who have written reviews on the largest
> number of books, as in the example nested document structures .
>
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Parent-Child-Nested-Document-Faceting-tp4211632p4220894.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
--------------------------

Benedetti Alessandro
Visiting card - http://about.me/alessandro_benedetti
Blog - http://alexbenedetti.blogspot.co.uk

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Reply via email to