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 <ysee...@gmail.com>: > 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