In the Solr documents above, there a two books. Each book has two pages, which will be loaded as a block with the master book records.
After loading we can issue the following parent block join query:
http://localhost:8983/solr/collection1/select?q={!parent which='type_s:parent'}text_t:solr&wt=xml&indent=true
This parent block join returns the parent book records for books where the child documents contain “solr” in the text_t field.
With the ExpandComponent, we can expand the results to include the children of the book records returned by the block join. For exmaple:
http://localhost:8983/solr/collection1/select?q={!parent which='type_s:parent'}text_t:solr&wt=xml&indent=true&expand=true&expand.field=ISBN_s&expand.q=*:*
The query above turns on the ExpandComponent with the expand=true parameter. The expand.field=ISBN_s parameter tells the ExpandComponent to group the expanded documents by the ISBN_s field. The expand.q=*:* tells the ExpandComponent to match all of the documents within the group. This is needed because by default the ExpandComponent uses the main query to determine which documents to match, which in this case was the block join.
With the ExpandComponent on, the results will have a new “expanded” section that contains the expanded child documents from the block join.
Read full article from Using the ExpandComponent to expand a Solr Block Join | Solr Evolved
No comments:
Post a Comment