Parent/Child (Nested Document) Faceting

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Parent/Child (Nested Document) Faceting

Yonik Seeley
Hey Folks, I'd love some feedback on the interface for nested document
faceting (or rather switching facet domains to/from parent/child).

See the bottom of this blog:
http://yonik.com/solr-nested-objects/

Issue #1: How to specify that one should change domains before faceting?

I originally started out with a new facet type (like query facet, but
switches domains).
So if you started out querying a child of type book, you would first
do a "blockParent" facet to map the domain to parents, and then put
the actual facet you wanted as a sub-facet.

q=book_review:xxxxxx  /* query some child-doc of book */
json.facet=
  {  // NOTE: this was my first pass... not the current interface
    books : {
      type: blockParent,
      parentFilter : "type:book"
      facet : {
        authors : {
          type : terms,
          field : author
        }
     }
  }

Although having a separate facet type to map domains is logically very
clean, it does introduce an additional level of indentation which may
not be desired.

So then I thought about including domain switching operations under a
"domain" directive in the facet itself:

json.facet=
{  // current form a domain switching facet
  authors : {
    type: terms,
    field: author,
    domain : {blockParent:"type:book"}
  }
}

I envision some future other options for "domain" including the
ability to reset the domain with another query (ignoring your parent
domain), or adding additional filters to the domain before faceting,
or normal (non-block) joins.

Issue #2: Naming

I avoided toParent and toChild because people cloud be confused that
it would work on any sort of parent/child relationship (i.e. other
than nested documents).

I used "blockParent" and "blockChildren" because I was thinking about
block join.
One alternative that might be better could be "nested" (i.e. nestedParent).

Pluralization:
I picked the singular for blockParent and plural for blockChildren
since a single block as one parent and multiple children.  But you
could think about it in other ways since we're mapping a set of
documents at a time (i.e. both could be pluralized).

Options:
nestedParent, nestedChildren   // current option
nestedParents, nestedChildren // both plural
nestedChild, nestedParent        // both singular

Feedback appreciated!

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Alessandro Benedetti-4
Hi Yonik,
I find the syntax quite expressive, only one question :

*1*) $ curl http://localhost:8983/solr/demo/query -d '
q=author_s:yonik&fl=id,comment_t&
json.facet={
  genres : {
    type: terms,
    field: cat_s,
    domain: { blockParent : "type_s:book" }
  }
}'

I read this :
Give me all the docs ( they will be type_s:review) that satisfy my query
and the facet on the parents ( that will be of type_s:book).
In this way I can calculate facets only on parents that are books.

*2*) $ 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" }
  }
}'

I read this :
Give me all the docs ( they will be type_s:book) that satisfy my query and
the facet on the children ( that will be of type_s:review).
In this way I can calculate facets only on children but without specifying
the type .

So why in both cases we express the parent type ? ( "Note that regardless
of which direction we are mapping (parents to children or children to
parents) we provide a query that defines the complete set of parents in the
index. In these examples, the parent filter is “type_s:book”. )

Is this necessary for implementation reasons ? Is there to prevent to use
other parent -children relations ? Why we don't specify the children type ?

Example:
*Parent types* : book
*Children types* : user_review, official_review

Assuming we have in the same index this data.
In two how can we distinguish between the 2 types of children ? or taking
both if we want ?
Is it not redundant the
"type_s:book" in 2 ?

Cheers


2015-06-14 2:02 GMT+01:00 Yonik Seeley <[hidden email]>:

> Hey Folks, I'd love some feedback on the interface for nested document
> faceting (or rather switching facet domains to/from parent/child).
>
> See the bottom of this blog:
> http://yonik.com/solr-nested-objects/
>
> Issue #1: How to specify that one should change domains before faceting?
>
> I originally started out with a new facet type (like query facet, but
> switches domains).
> So if you started out querying a child of type book, you would first
> do a "blockParent" facet to map the domain to parents, and then put
> the actual facet you wanted as a sub-facet.
>
> q=book_review:xxxxxx  /* query some child-doc of book */
> json.facet=
>   {  // NOTE: this was my first pass... not the current interface
>     books : {
>       type: blockParent,
>       parentFilter : "type:book"
>       facet : {
>         authors : {
>           type : terms,
>           field : author
>         }
>      }
>   }
>
> Although having a separate facet type to map domains is logically very
> clean, it does introduce an additional level of indentation which may
> not be desired.
>
> So then I thought about including domain switching operations under a
> "domain" directive in the facet itself:
>
> json.facet=
> {  // current form a domain switching facet
>   authors : {
>     type: terms,
>     field: author,
>     domain : {blockParent:"type:book"}
>   }
> }
>
> I envision some future other options for "domain" including the
> ability to reset the domain with another query (ignoring your parent
> domain), or adding additional filters to the domain before faceting,
> or normal (non-block) joins.
>
> Issue #2: Naming
>
> I avoided toParent and toChild because people cloud be confused that
> it would work on any sort of parent/child relationship (i.e. other
> than nested documents).
>
> I used "blockParent" and "blockChildren" because I was thinking about
> block join.
> One alternative that might be better could be "nested" (i.e. nestedParent).
>
> Pluralization:
> I picked the singular for blockParent and plural for blockChildren
> since a single block as one parent and multiple children.  But you
> could think about it in other ways since we're mapping a set of
> documents at a time (i.e. both could be pluralized).
>
> Options:
> nestedParent, nestedChildren   // current option
> nestedParents, nestedChildren // both plural
> nestedChild, nestedParent        // both singular
>
> Feedback appreciated!
>
> -Yonik
>



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

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"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 | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Yonik Seeley
On Mon, Jun 15, 2015 at 10:24 AM, Alessandro Benedetti
<[hidden email]> wrote:
> So why in both cases we express the parent type ?
>
> ( "Note that regardless
> of which direction we are mapping (parents to children or children to
> parents) we provide a query that defines the complete set of parents in the
> index. In these examples, the parent filter is “type_s:book”. )
>
> Is this necessary for implementation reasons ? Is there to prevent to use
> other parent -children relations ? Why we don't specify the children type ?

That's just an implementation detail that separates the parents from
the children.
It's the way the original block join queries worked, so I just kept that part.
One could easily pass children and then assume that anything that
isn't marked as a child is a parent, but it would be different code to
implement that.

In the future, we may index more information by default when you index
nested child docs that would normally make specifying the parent
filter optional.

> Example:
> *Parent types* : book
> *Children types* : user_review, official_review
>
> Assuming we have in the same index this data.
> In two how can we distinguish between the 2 types of children ?

Today, it's up to whoever is indexing the nested documents to add type
information (like type:book, type:review).  There are no requirements
on how this is done.  In the example above, you could have
type:user_review and type:official_review or you could keep the type
as "review" and add an additional "isOfficial:true/false" to
distinguish.

Then if we're mapping from children to parents, it's the
responsibility of the base query and filters (or however the facet
domain got created) to limit to one child type if they want.

For example, a filter might be fq=isOfficial:true of you are only
querying official reviews

*But* for mapping from parents to children, you've quickly identified
a weakness that is on my TODO list ;-)
Currently all children (and grandchildren, if multi-leveled) will be
selected when using blockChildren.  We need a filter (or filters) to
apply after the transition to screen out only those children we are
interested in *before* we calculate the facets.  That would include
type info (in the case of multiple child types), but wouldn't be
limited to that.

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

dxxd116
This post was updated on .
In reply to this post by Yonik Seeley
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 .

$ 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" }
  }
}'


This query will return the number of reviews for each author. If that author has 2 reviews for the same book, the counter would be increased by 2.
If I want to just count the book, not the reviews. How could that be done?

Thanks,
Xingliang
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Alessandro Benedetti-4
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 <[hidden email]>:

> 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 | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Mikhail Khludnev
In reply to this post by Yonik Seeley
Yonik,

I wonder is there a plan or a vision for something like
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
under JSON facets?

Thanks

On Sun, Jun 14, 2015 at 4:02 AM, Yonik Seeley <[hidden email]> wrote:

> Hey Folks, I'd love some feedback on the interface for nested document
> faceting (or rather switching facet domains to/from parent/child).
>
> See the bottom of this blog:
> http://yonik.com/solr-nested-objects/
>
> Issue #1: How to specify that one should change domains before faceting?
>
> I originally started out with a new facet type (like query facet, but
> switches domains).
> So if you started out querying a child of type book, you would first
> do a "blockParent" facet to map the domain to parents, and then put
> the actual facet you wanted as a sub-facet.
>
> q=book_review:xxxxxx  /* query some child-doc of book */
> json.facet=
>   {  // NOTE: this was my first pass... not the current interface
>     books : {
>       type: blockParent,
>       parentFilter : "type:book"
>       facet : {
>         authors : {
>           type : terms,
>           field : author
>         }
>      }
>   }
>
> Although having a separate facet type to map domains is logically very
> clean, it does introduce an additional level of indentation which may
> not be desired.
>
> So then I thought about including domain switching operations under a
> "domain" directive in the facet itself:
>
> json.facet=
> {  // current form a domain switching facet
>   authors : {
>     type: terms,
>     field: author,
>     domain : {blockParent:"type:book"}
>   }
> }
>
> I envision some future other options for "domain" including the
> ability to reset the domain with another query (ignoring your parent
> domain), or adding additional filters to the domain before faceting,
> or normal (non-block) joins.
>
> Issue #2: Naming
>
> I avoided toParent and toChild because people cloud be confused that
> it would work on any sort of parent/child relationship (i.e. other
> than nested documents).
>
> I used "blockParent" and "blockChildren" because I was thinking about
> block join.
> One alternative that might be better could be "nested" (i.e. nestedParent).
>
> Pluralization:
> I picked the singular for blockParent and plural for blockChildren
> since a single block as one parent and multiple children.  But you
> could think about it in other ways since we're mapping a set of
> documents at a time (i.e. both could be pluralized).
>
> Options:
> nestedParent, nestedChildren   // current option
> nestedParents, nestedChildren // both plural
> nestedChild, nestedParent        // both singular
>
> Feedback appreciated!
>
> -Yonik
>



--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Yonik Seeley
On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
<[hidden email]> wrote:
> Yonik,
>
> I wonder is there a plan or a vision for something like
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
> under JSON facets?

Hmmm, I couldn't quite grok that complicated command syntax... but the
description seems straight-forward enough:

"The following aggregations will return the top commenters' username
that have commented and per top commenter the top tags of the issues
the user has commented on:"

So if I translate that into "books" and "reviews" that I use here:
http://yonik.com/solr-nested-objects/

it sounds like we start with a set of book objects, then map to the
child domain to facet on comments, then map back to the parent domain
to facet on books again.

From that blog, this is the command that finds top review authors:

json.facet={
  top_reviewers : {
    type: terms,
    field: author_s,
    domain: { blockChildren : "type_s:book" }
  }
}

Now we just need to add a sub-facet that switches back to the parent
domain to facet on something there (like genre... equiv to "tags" in
the ES example):

son.facet={
  top_reviewers : {
    type: terms,
    field: author_s,
    domain: { blockChildren : "type_s:book" },

    facet : {
      type:terms,
      field:genre,
      domain:{blockParent:"type_s:book"}
    }

  }
}



While there is certainly more work do be done with joins /
block-joins, it seems like we can already do that specific example at
least.

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Alessandro Benedetti
Adding to Yonik response,
I think the feature shown by the Elastic Search blog is simply the
"Faceting on Parents" one,

"A special single bucket aggregation that enables aggregating on parent
docs from nested documents. "


Indeed it seems to not search on the parents then facets on children and
then on parents, it doesn't show the search but only the faceting at
children and parent level.
From the line I quoted,we can guess it is searching at the children level,
faceting on the children and then faceting on the parents.
Then it describes a path to filter to a specific level of parents.
Anyway everything seems possible to me trough the ( I love it, can stop to
repeat it) Json Facet Approach.
Never tried with multiple hierarchical object levels, but I assume it
should not be a problem , using properly the domain: { blockParent :
"type_s:book" }  according to the level you want.

Cheers


[1] Yonik Blog quote

Faceting on Parents

> The main query gives us a document list of reviews by author_s:yonik
> If we want to facet on the book genre (cat_s field) then we need to
> switch the domain from the children (type_s:reviews) to the parents
> (type_s:books).
> $ curl http://localhost:8983/solr/demo/query -d '
> q=author_s:yonik&fl=id,comment_t&
> json.facet={
>   genres : {
>     type: terms,
>     field: cat_s,
>     domain: { blockParent : "type_s:book" }
>   }
> }'
> And we get a facet over the books which yonik reviewed:
> "response":{"numFound":2,"start":0,"docs":[
>     {
>       "id":"book1_c1",
>       "comment_t":["A great start to what looks like an epic series!"]},
>     {
>       "id":"book2_c1",
>       "comment_t":["Ahead of its time... I wonder if it helped inspire
> The Matrix?"]}]
> },
> "facets":{
>   "count":2,
>   "genres":{
>     "buckets":[{
>         "val":"fantasy",
>         "count":1},
>       {
>         "val":"sci-fi",
>         "count":1}]
> }}


On 11 November 2015 at 15:31, Yonik Seeley <[hidden email]> wrote:

> On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
> <[hidden email]> wrote:
> > Yonik,
> >
> > I wonder is there a plan or a vision for something like
> >
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
> > under JSON facets?
>
> Hmmm, I couldn't quite grok that complicated command syntax... but the
> description seems straight-forward enough:
>
> "The following aggregations will return the top commenters' username
> that have commented and per top commenter the top tags of the issues
> the user has commented on:"
>
> So if I translate that into "books" and "reviews" that I use here:
> http://yonik.com/solr-nested-objects/
>
> it sounds like we start with a set of book objects, then map to the
> child domain to facet on comments, then map back to the parent domain
> to facet on books again.
>
> From that blog, this is the command that finds top review authors:
>
> json.facet={
>   top_reviewers : {
>     type: terms,
>     field: author_s,
>     domain: { blockChildren : "type_s:book" }
>   }
> }
>
> Now we just need to add a sub-facet that switches back to the parent
> domain to facet on something there (like genre... equiv to "tags" in
> the ES example):
>
> son.facet={
>   top_reviewers : {
>     type: terms,
>     field: author_s,
>     domain: { blockChildren : "type_s:book" },
>
>     facet : {
>       type:terms,
>       field:genre,
>       domain:{blockParent:"type_s:book"}
>     }
>
>   }
> }
>
>
>
> While there is certainly more work do be done with joins /
> block-joins, it seems like we can already do that specific example at
> least.
>
> -Yonik
>



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

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"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
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Yonik Seeley
On Wed, Nov 11, 2015 at 12:34 PM, Alessandro Benedetti
<[hidden email]> wrote:
> Anyway everything seems possible to me trough the ( I love it, can stop to
> repeat it) Json Facet Approach.

Thanks, the positive feedback definitely gives me motivation to keep
improving it!

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Mikhail Khludnev
In reply to this post by Yonik Seeley
I found that example has not enough data to reproduce this functionality.
what if Mary left the same comment to the same book (book2_c4), then we
search for th* across comments

http://localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=csv&indent=true&fl=author_s,comment_t,id

and get

author_s,comment_t,id
dan,This book was too long.,book1_c2
yonik,Ahead of its time... I wonder if it helped inspire The Matrix?,book2_c1
dan,A pizza boy for the Mafia franchise? Really?,book2_c2
mary,Neal is so creative and detailed! Loved the metaverse!,book2_c3
mary,Neal is so creative and detailed! Loved the metaverse!,book2_c4

then, I wish to calculate author facet, but count them in books
(rollup to parents)!

dan(2) - commented both books
yonik(1) - only second one
*mary(1)*  - only second one, despite twice

So, far I'm ablle only

localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
: { type: terms, field: author_s}}

"top_reviewers":{
      "buckets":[{
          "val":"dan",
          "count":2},
        {
          "val":"mary",
          "count":2},
        {
          "val":"yonik",
          "count":1}]}}}

but it's comments mary(2), not books!

Neither  domain: { blockParent : "type_s:book" } nor  domain: {
blockChildren : "type_s:book" } don't help.

I tried to nest a facet with specifying a domain, it's just ignored
localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
: { type: terms, field: author_s, in_books : { type: terms, field:
author_s,  domain: { blockParent : \"type_s:book\" }}}}




On Wed, Nov 11, 2015 at 6:31 PM, Yonik Seeley <[hidden email]> wrote:

> On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
> <[hidden email]> wrote:
> > Yonik,
> >
> > I wonder is there a plan or a vision for something like
> >
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
> > under JSON facets?
>
> Hmmm, I couldn't quite grok that complicated command syntax... but the
> description seems straight-forward enough:
>
> "The following aggregations will return the top commenters' username
> that have commented and per top commenter the top tags of the issues
> the user has commented on:"
>
> So if I translate that into "books" and "reviews" that I use here:
> http://yonik.com/solr-nested-objects/
>
> it sounds like we start with a set of book objects, then map to the
> child domain to facet on comments, then map back to the parent domain
> to facet on books again.
>
> From that blog, this is the command that finds top review authors:
>
> json.facet={
>   top_reviewers : {
>     type: terms,
>     field: author_s,
>     domain: { blockChildren : "type_s:book" }
>   }
> }
>
> Now we just need to add a sub-facet that switches back to the parent
> domain to facet on something there (like genre... equiv to "tags" in
> the ES example):
>
> son.facet={
>   top_reviewers : {
>     type: terms,
>     field: author_s,
>     domain: { blockChildren : "type_s:book" },
>
>     facet : {
>       type:terms,
>       field:genre,
>       domain:{blockParent:"type_s:book"}
>     }
>
>   }
> }
>
>
>
> While there is certainly more work do be done with joins /
> block-joins, it seems like we can already do that specific example at
> least.
>
> -Yonik
>



--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Alessandro Benedetti
Hi Mikhail,
how about this :

json.facet={
    top_reviewers: {
        type: terms,
        field: author_s,
        sort: "booksCount desc",
        facet: {
            booksCount: "unique(_root_)"
        }
    }
}

We query on children ( comments) and we calculate that facets.
This should satisfy your test requirement:

http://localhost:8983/solr/demo/select?q=*:*&wt=json&indent=true&fl=id,comment_t&json.facet={top_reviewers:
{type: terms,field: author_s,sort: "booksCount desc",facet: {booksCount:
"unique(_root_)"}}}

Example Response :

"top_reviewers":{
      "buckets":[{
          "val":"dan",
          "count":2,
          "booksCount":2},
        {
          "val":"yonik",
          "count":2,
          "booksCount":2},
        {
          "val":"Brandon Sanderson",
          "count":1,
          "booksCount":1},
        *{
          "val":"Mary",
          "count":2,
          "booksCount":1}*

...

Wondering which kind of scenarios can rise if we consider a multi-level
hierarchy...

Cheers

On 11 November 2015 at 22:26, Mikhail Khludnev <[hidden email]>
wrote:

> I found that example has not enough data to reproduce this functionality.
> what if Mary left the same comment to the same book (book2_c4), then we
> search for th* across comments
>
>
> http://localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=csv&indent=true&fl=author_s,comment_t,id
>
> and get
>
> author_s,comment_t,id
> dan,This book was too long.,book1_c2
> yonik,Ahead of its time... I wonder if it helped inspire The
> Matrix?,book2_c1
> dan,A pizza boy for the Mafia franchise? Really?,book2_c2
> mary,Neal is so creative and detailed! Loved the metaverse!,book2_c3
> mary,Neal is so creative and detailed! Loved the metaverse!,book2_c4
>
> then, I wish to calculate author facet, but count them in books
> (rollup to parents)!
>
> dan(2) - commented both books
> yonik(1) - only second one
> *mary(1)*  - only second one, despite twice
>
> So, far I'm ablle only
>
>
> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
> : { type: terms, field: author_s}}
>
> "top_reviewers":{
>       "buckets":[{
>           "val":"dan",
>           "count":2},
>         {
>           "val":"mary",
>           "count":2},
>         {
>           "val":"yonik",
>           "count":1}]}}}
>
> but it's comments mary(2), not books!
>
> Neither  domain: { blockParent : "type_s:book" } nor  domain: {
> blockChildren : "type_s:book" } don't help.
>
> I tried to nest a facet with specifying a domain, it's just ignored
>
> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
> : { type: terms, field: author_s, in_books : { type: terms, field:
> author_s,  domain: { blockParent : \"type_s:book\" }}}}
>
>
>
>
> On Wed, Nov 11, 2015 at 6:31 PM, Yonik Seeley <[hidden email]> wrote:
>
> > On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
> > <[hidden email]> wrote:
> > > Yonik,
> > >
> > > I wonder is there a plan or a vision for something like
> > >
> >
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
> > > under JSON facets?
> >
> > Hmmm, I couldn't quite grok that complicated command syntax... but the
> > description seems straight-forward enough:
> >
> > "The following aggregations will return the top commenters' username
> > that have commented and per top commenter the top tags of the issues
> > the user has commented on:"
> >
> > So if I translate that into "books" and "reviews" that I use here:
> > http://yonik.com/solr-nested-objects/
> >
> > it sounds like we start with a set of book objects, then map to the
> > child domain to facet on comments, then map back to the parent domain
> > to facet on books again.
> >
> > From that blog, this is the command that finds top review authors:
> >
> > json.facet={
> >   top_reviewers : {
> >     type: terms,
> >     field: author_s,
> >     domain: { blockChildren : "type_s:book" }
> >   }
> > }
> >
> > Now we just need to add a sub-facet that switches back to the parent
> > domain to facet on something there (like genre... equiv to "tags" in
> > the ES example):
> >
> > son.facet={
> >   top_reviewers : {
> >     type: terms,
> >     field: author_s,
> >     domain: { blockChildren : "type_s:book" },
> >
> >     facet : {
> >       type:terms,
> >       field:genre,
> >       domain:{blockParent:"type_s:book"}
> >     }
> >
> >   }
> > }
> >
> >
> >
> > While there is certainly more work do be done with joins /
> > block-joins, it seems like we can already do that specific example at
> > least.
> >
> > -Yonik
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
> <[hidden email]>
>



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

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"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
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Alessandro Benedetti
I was experimenting with multi-level hierarchy of nested objects.

the _root_ field will always point to  the root parent id.
If I model Books - Reviews - Comments , where do I have the reference to
the parent ?
I think we are getting closer to the understanding of the ES functionality.

It should allow to search in Level N ( comments for example) and then facet
over the unique values of :
1) parent - Given my comments to reviews of books, count all the different
reviews I commented* ( wondering how to access the parent of a child)*
2) grand parent - Given my comments to reviews of books, count all the
different books, I commented a review of ( tried this and it is working)
3) Any ancestor though the path

Cheers

On 12 November 2015 at 10:25, Alessandro Benedetti <[hidden email]>
wrote:

> Hi Mikhail,
> how about this :
>
> json.facet={
>     top_reviewers: {
>         type: terms,
>         field: author_s,
>         sort: "booksCount desc",
>         facet: {
>             booksCount: "unique(_root_)"
>         }
>     }
> }
>
> We query on children ( comments) and we calculate that facets.
> This should satisfy your test requirement:
>
>
> http://localhost:8983/solr/demo/select?q=*:*&wt=json&indent=true&fl=id,comment_t&json.facet={top_reviewers:
> {type: terms,field: author_s,sort: "booksCount desc",facet: {booksCount:
> "unique(_root_)"}}}
>
> Example Response :
>
> "top_reviewers":{
>       "buckets":[{
>           "val":"dan",
>           "count":2,
>           "booksCount":2},
>         {
>           "val":"yonik",
>           "count":2,
>           "booksCount":2},
>         {
>           "val":"Brandon Sanderson",
>           "count":1,
>           "booksCount":1},
>         *{
>           "val":"Mary",
>           "count":2,
>           "booksCount":1}*
>
> ...
>
> Wondering which kind of scenarios can rise if we consider a multi-level
> hierarchy...
>
> Cheers
>
> On 11 November 2015 at 22:26, Mikhail Khludnev <[hidden email]
> > wrote:
>
>> I found that example has not enough data to reproduce this functionality.
>> what if Mary left the same comment to the same book (book2_c4), then we
>> search for th* across comments
>>
>>
>> http://localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=csv&indent=true&fl=author_s,comment_t,id
>>
>> and get
>>
>> author_s,comment_t,id
>> dan,This book was too long.,book1_c2
>> yonik,Ahead of its time... I wonder if it helped inspire The
>> Matrix?,book2_c1
>> dan,A pizza boy for the Mafia franchise? Really?,book2_c2
>> mary,Neal is so creative and detailed! Loved the metaverse!,book2_c3
>> mary,Neal is so creative and detailed! Loved the metaverse!,book2_c4
>>
>> then, I wish to calculate author facet, but count them in books
>> (rollup to parents)!
>>
>> dan(2) - commented both books
>> yonik(1) - only second one
>> *mary(1)*  - only second one, despite twice
>>
>> So, far I'm ablle only
>>
>>
>> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
>> : { type: terms, field: author_s}}
>>
>> "top_reviewers":{
>>       "buckets":[{
>>           "val":"dan",
>>           "count":2},
>>         {
>>           "val":"mary",
>>           "count":2},
>>         {
>>           "val":"yonik",
>>           "count":1}]}}}
>>
>> but it's comments mary(2), not books!
>>
>> Neither  domain: { blockParent : "type_s:book" } nor  domain: {
>> blockChildren : "type_s:book" } don't help.
>>
>> I tried to nest a facet with specifying a domain, it's just ignored
>>
>> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
>> : { type: terms, field: author_s, in_books : { type: terms, field:
>> author_s,  domain: { blockParent : \"type_s:book\" }}}}
>>
>>
>>
>>
>> On Wed, Nov 11, 2015 at 6:31 PM, Yonik Seeley <[hidden email]> wrote:
>>
>> > On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
>> > <[hidden email]> wrote:
>> > > Yonik,
>> > >
>> > > I wonder is there a plan or a vision for something like
>> > >
>> >
>> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
>> > > under JSON facets?
>> >
>> > Hmmm, I couldn't quite grok that complicated command syntax... but the
>> > description seems straight-forward enough:
>> >
>> > "The following aggregations will return the top commenters' username
>> > that have commented and per top commenter the top tags of the issues
>> > the user has commented on:"
>> >
>> > So if I translate that into "books" and "reviews" that I use here:
>> > http://yonik.com/solr-nested-objects/
>> >
>> > it sounds like we start with a set of book objects, then map to the
>> > child domain to facet on comments, then map back to the parent domain
>> > to facet on books again.
>> >
>> > From that blog, this is the command that finds top review authors:
>> >
>> > json.facet={
>> >   top_reviewers : {
>> >     type: terms,
>> >     field: author_s,
>> >     domain: { blockChildren : "type_s:book" }
>> >   }
>> > }
>> >
>> > Now we just need to add a sub-facet that switches back to the parent
>> > domain to facet on something there (like genre... equiv to "tags" in
>> > the ES example):
>> >
>> > son.facet={
>> >   top_reviewers : {
>> >     type: terms,
>> >     field: author_s,
>> >     domain: { blockChildren : "type_s:book" },
>> >
>> >     facet : {
>> >       type:terms,
>> >       field:genre,
>> >       domain:{blockParent:"type_s:book"}
>> >     }
>> >
>> >   }
>> > }
>> >
>> >
>> >
>> > While there is certainly more work do be done with joins /
>> > block-joins, it seems like we can already do that specific example at
>> > least.
>> >
>> > -Yonik
>> >
>>
>>
>>
>> --
>> Sincerely yours
>> Mikhail Khludnev
>> Principal Engineer,
>> Grid Dynamics
>>
>> <http://www.griddynamics.com>
>> <[hidden email]>
>>
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "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
>



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

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"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
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Alessandro Benedetti
Last addition, in the case of multi-level hierarchy.
I think I found what we can not reproduce :

*json.facet*={
    top_reviewers: {
        type: terms,
        field: author_s,
        facet: {
            reviewCount: "unique(parent_s)",
            facet: {
                type: terms,
                field: id,
                domain: {
                    blockParent: "type_s:book"
                },
       facet: {
           bookCount: "unique(id)"}
            }
        }
    }
}

Example Response :

facets":{
    "count":7,
    "top_reviewers":{
      "buckets":[{
          "val":"commenterYonik",
          "count":4,
          "reviewCount":2,
          "facet":{
            "buckets":[{
                "val":"book1",
                "count":1,
                *"bookCount":1},*
              {
                "val":"book2",
                "count":1,
                *"bookCount":1}]}},*
        {
          "val":"commenterAlex",
          "count":3,
          "reviewCount":2,
          "facet":{
            "buckets":[{
                "val":"book2",
                "count":1,
               * "bookCount":1*}]}}]}}}


Ideally I want to be able to move bookCount stat at the level of
reviewCount ( using a sort of path in the ancestors) .
Something like :

json.facet={
    top_reviewers: {
        type: terms,
        field: author_s,
        facet: {
            reviewCount: "unique(parent_s)",
            stat: {
                domain: {
                    blockParent: "type_s:review"
                },
                bookCount: "unique(parent_s)"
            }
        }
    }
}

The 3 level edge case could be solved using a parent_s field and the _root_
field.

But in a N level scenario we would need a way to specify a path and be able
to provide this kind of analytics.

Sorry for the spam.


Cheers

On 12 November 2015 at 11:15, Alessandro Benedetti <[hidden email]>
wrote:

> I was experimenting with multi-level hierarchy of nested objects.
>
> the _root_ field will always point to  the root parent id.
> If I model Books - Reviews - Comments , where do I have the reference to
> the parent ?
> I think we are getting closer to the understanding of the ES functionality.
>
> It should allow to search in Level N ( comments for example) and then
> facet over the unique values of :
> 1) parent - Given my comments to reviews of books, count all the different
> reviews I commented* ( wondering how to access the parent of a child)*
> 2) grand parent - Given my comments to reviews of books, count all the
> different books, I commented a review of ( tried this and it is working)
> 3) Any ancestor though the path
>
> Cheers
>
> On 12 November 2015 at 10:25, Alessandro Benedetti <[hidden email]>
> wrote:
>
>> Hi Mikhail,
>> how about this :
>>
>> json.facet={
>>     top_reviewers: {
>>         type: terms,
>>         field: author_s,
>>         sort: "booksCount desc",
>>         facet: {
>>             booksCount: "unique(_root_)"
>>         }
>>     }
>> }
>>
>> We query on children ( comments) and we calculate that facets.
>> This should satisfy your test requirement:
>>
>>
>> http://localhost:8983/solr/demo/select?q=*:*&wt=json&indent=true&fl=id,comment_t&json.facet={top_reviewers:
>> {type: terms,field: author_s,sort: "booksCount desc",facet: {booksCount:
>> "unique(_root_)"}}}
>>
>> Example Response :
>>
>> "top_reviewers":{
>>       "buckets":[{
>>           "val":"dan",
>>           "count":2,
>>           "booksCount":2},
>>         {
>>           "val":"yonik",
>>           "count":2,
>>           "booksCount":2},
>>         {
>>           "val":"Brandon Sanderson",
>>           "count":1,
>>           "booksCount":1},
>>         *{
>>           "val":"Mary",
>>           "count":2,
>>           "booksCount":1}*
>>
>> ...
>>
>> Wondering which kind of scenarios can rise if we consider a multi-level
>> hierarchy...
>>
>> Cheers
>>
>> On 11 November 2015 at 22:26, Mikhail Khludnev <
>> [hidden email]> wrote:
>>
>>> I found that example has not enough data to reproduce this functionality.
>>> what if Mary left the same comment to the same book (book2_c4), then we
>>> search for th* across comments
>>>
>>>
>>> http://localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=csv&indent=true&fl=author_s,comment_t,id
>>>
>>> and get
>>>
>>> author_s,comment_t,id
>>> dan,This book was too long.,book1_c2
>>> yonik,Ahead of its time... I wonder if it helped inspire The
>>> Matrix?,book2_c1
>>> dan,A pizza boy for the Mafia franchise? Really?,book2_c2
>>> mary,Neal is so creative and detailed! Loved the metaverse!,book2_c3
>>> mary,Neal is so creative and detailed! Loved the metaverse!,book2_c4
>>>
>>> then, I wish to calculate author facet, but count them in books
>>> (rollup to parents)!
>>>
>>> dan(2) - commented both books
>>> yonik(1) - only second one
>>> *mary(1)*  - only second one, despite twice
>>>
>>> So, far I'm ablle only
>>>
>>>
>>> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
>>> : { type: terms, field: author_s}}
>>>
>>> "top_reviewers":{
>>>       "buckets":[{
>>>           "val":"dan",
>>>           "count":2},
>>>         {
>>>           "val":"mary",
>>>           "count":2},
>>>         {
>>>           "val":"yonik",
>>>           "count":1}]}}}
>>>
>>> but it's comments mary(2), not books!
>>>
>>> Neither  domain: { blockParent : "type_s:book" } nor  domain: {
>>> blockChildren : "type_s:book" } don't help.
>>>
>>> I tried to nest a facet with specifying a domain, it's just ignored
>>>
>>> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
>>> : { type: terms, field: author_s, in_books : { type: terms, field:
>>> author_s,  domain: { blockParent : \"type_s:book\" }}}}
>>>
>>>
>>>
>>>
>>> On Wed, Nov 11, 2015 at 6:31 PM, Yonik Seeley <[hidden email]> wrote:
>>>
>>> > On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
>>> > <[hidden email]> wrote:
>>> > > Yonik,
>>> > >
>>> > > I wonder is there a plan or a vision for something like
>>> > >
>>> >
>>> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
>>> > > under JSON facets?
>>> >
>>> > Hmmm, I couldn't quite grok that complicated command syntax... but the
>>> > description seems straight-forward enough:
>>> >
>>> > "The following aggregations will return the top commenters' username
>>> > that have commented and per top commenter the top tags of the issues
>>> > the user has commented on:"
>>> >
>>> > So if I translate that into "books" and "reviews" that I use here:
>>> > http://yonik.com/solr-nested-objects/
>>> >
>>> > it sounds like we start with a set of book objects, then map to the
>>> > child domain to facet on comments, then map back to the parent domain
>>> > to facet on books again.
>>> >
>>> > From that blog, this is the command that finds top review authors:
>>> >
>>> > json.facet={
>>> >   top_reviewers : {
>>> >     type: terms,
>>> >     field: author_s,
>>> >     domain: { blockChildren : "type_s:book" }
>>> >   }
>>> > }
>>> >
>>> > Now we just need to add a sub-facet that switches back to the parent
>>> > domain to facet on something there (like genre... equiv to "tags" in
>>> > the ES example):
>>> >
>>> > son.facet={
>>> >   top_reviewers : {
>>> >     type: terms,
>>> >     field: author_s,
>>> >     domain: { blockChildren : "type_s:book" },
>>> >
>>> >     facet : {
>>> >       type:terms,
>>> >       field:genre,
>>> >       domain:{blockParent:"type_s:book"}
>>> >     }
>>> >
>>> >   }
>>> > }
>>> >
>>> >
>>> >
>>> > While there is certainly more work do be done with joins /
>>> > block-joins, it seems like we can already do that specific example at
>>> > least.
>>> >
>>> > -Yonik
>>> >
>>>
>>>
>>>
>>> --
>>> Sincerely yours
>>> Mikhail Khludnev
>>> Principal Engineer,
>>> Grid Dynamics
>>>
>>> <http://www.griddynamics.com>
>>> <[hidden email]>
>>>
>>
>>
>>
>> --
>> --------------------------
>>
>> Benedetti Alessandro
>> Visiting card : http://about.me/alessandro_benedetti
>>
>> "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
>>
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "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
>



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

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"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
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
Reply | Threaded
Open this post in threaded view
|

Re: Parent/Child (Nested Document) Faceting

Mikhail Khludnev
In reply to this post by Alessandro Benedetti
Alessandro,

> facet: {booksCount:"unique(_root_)"}
is a pretty cool finding. it's what literally Elastic does in
"reverse-nested-aggregation". it's interesting how much it costs for
shards. I'll look deeper.
Thanks, Alessandro!
Yonik, JSON Facets rocks!

On Thu, Nov 12, 2015 at 1:25 PM, Alessandro Benedetti <[hidden email]
> wrote:

> Hi Mikhail,
> how about this :
>
> json.facet={
>     top_reviewers: {
>         type: terms,
>         field: author_s,
>         sort: "booksCount desc",
>         facet: {
>             booksCount: "unique(_root_)"
>         }
>     }
> }
>
> We query on children ( comments) and we calculate that facets.
> This should satisfy your test requirement:
>
>
> http://localhost:8983/solr/demo/select?q=*:*&wt=json&indent=true&fl=id,comment_t&json.facet={top_reviewers
> :
> {type: terms,field: author_s,sort: "booksCount desc",facet: {booksCount:
> "unique(_root_)"}}}
>
> Example Response :
>
> "top_reviewers":{
>       "buckets":[{
>           "val":"dan",
>           "count":2,
>           "booksCount":2},
>         {
>           "val":"yonik",
>           "count":2,
>           "booksCount":2},
>         {
>           "val":"Brandon Sanderson",
>           "count":1,
>           "booksCount":1},
>         *{
>           "val":"Mary",
>           "count":2,
>           "booksCount":1}*
>
> ...
>
> Wondering which kind of scenarios can rise if we consider a multi-level
> hierarchy...
>
> Cheers
>
> On 11 November 2015 at 22:26, Mikhail Khludnev <[hidden email]
> >
> wrote:
>
> > I found that example has not enough data to reproduce this functionality.
> > what if Mary left the same comment to the same book (book2_c4), then we
> > search for th* across comments
> >
> >
> >
> http://localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=csv&indent=true&fl=author_s,comment_t,id
> >
> > and get
> >
> > author_s,comment_t,id
> > dan,This book was too long.,book1_c2
> > yonik,Ahead of its time... I wonder if it helped inspire The
> > Matrix?,book2_c1
> > dan,A pizza boy for the Mafia franchise? Really?,book2_c2
> > mary,Neal is so creative and detailed! Loved the metaverse!,book2_c3
> > mary,Neal is so creative and detailed! Loved the metaverse!,book2_c4
> >
> > then, I wish to calculate author facet, but count them in books
> > (rollup to parents)!
> >
> > dan(2) - commented both books
> > yonik(1) - only second one
> > *mary(1)*  - only second one, despite twice
> >
> > So, far I'm ablle only
> >
> >
> >
> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
> > : { type: terms, field: author_s}}
> >
> > "top_reviewers":{
> >       "buckets":[{
> >           "val":"dan",
> >           "count":2},
> >         {
> >           "val":"mary",
> >           "count":2},
> >         {
> >           "val":"yonik",
> >           "count":1}]}}}
> >
> > but it's comments mary(2), not books!
> >
> > Neither  domain: { blockParent : "type_s:book" } nor  domain: {
> > blockChildren : "type_s:book" } don't help.
> >
> > I tried to nest a facet with specifying a domain, it's just ignored
> >
> >
> localhost:8983/solr/techproducts/select?q=comment_t%3Ath*&wt=json&indent=true&fl=author_s,comment_t,id&json.facet={top_reviewers
> > : { type: terms, field: author_s, in_books : { type: terms, field:
> > author_s,  domain: { blockParent : \"type_s:book\" }}}}
> >
> >
> >
> >
> > On Wed, Nov 11, 2015 at 6:31 PM, Yonik Seeley <[hidden email]> wrote:
> >
> > > On Mon, Nov 9, 2015 at 2:37 PM, Mikhail Khludnev
> > > <[hidden email]> wrote:
> > > > Yonik,
> > > >
> > > > I wonder is there a plan or a vision for something like
> > > >
> > >
> >
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
> > > > under JSON facets?
> > >
> > > Hmmm, I couldn't quite grok that complicated command syntax... but the
> > > description seems straight-forward enough:
> > >
> > > "The following aggregations will return the top commenters' username
> > > that have commented and per top commenter the top tags of the issues
> > > the user has commented on:"
> > >
> > > So if I translate that into "books" and "reviews" that I use here:
> > > http://yonik.com/solr-nested-objects/
> > >
> > > it sounds like we start with a set of book objects, then map to the
> > > child domain to facet on comments, then map back to the parent domain
> > > to facet on books again.
> > >
> > > From that blog, this is the command that finds top review authors:
> > >
> > > json.facet={
> > >   top_reviewers : {
> > >     type: terms,
> > >     field: author_s,
> > >     domain: { blockChildren : "type_s:book" }
> > >   }
> > > }
> > >
> > > Now we just need to add a sub-facet that switches back to the parent
> > > domain to facet on something there (like genre... equiv to "tags" in
> > > the ES example):
> > >
> > > son.facet={
> > >   top_reviewers : {
> > >     type: terms,
> > >     field: author_s,
> > >     domain: { blockChildren : "type_s:book" },
> > >
> > >     facet : {
> > >       type:terms,
> > >       field:genre,
> > >       domain:{blockParent:"type_s:book"}
> > >     }
> > >
> > >   }
> > > }
> > >
> > >
> > >
> > > While there is certainly more work do be done with joins /
> > > block-joins, it seems like we can already do that specific example at
> > > least.
> > >
> > > -Yonik
> > >
> >
> >
> >
> > --
> > Sincerely yours
> > Mikhail Khludnev
> > Principal Engineer,
> > Grid Dynamics
> >
> > <http://www.griddynamics.com>
> > <[hidden email]>
> >
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "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
>



--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<[hidden email]>