http://wiki.apache.org/solr/Join
q={!join from=manu_id_s to=id}ipod
you specify the foreign key relationship by giving the from and to fields to join on.
http://localhost:8983/solr/select?q=ipod&fl=*,score&sort=score+desc&fq={!join+from=id+to=manu_id_s}compName_s:%28Belkin%20Apple%29
http://blog.griddynamics.com/2013/09/solr-block-join-support.html
SolrInputDocument has new methods getChildDocuments()/addChildDocument() for nesting child documents into a parent document. XML and Javabin formats are now capable to transfer them.
q={!parent which='type_s:parent'}+COLOR_s:Red +SIZE_s:XL
Local parameter ‘which’ provides a filter which distinguishes parent documents from children ones. Keep in mind two important things about it:
it should not match any children documents;
it should always match all parent documents.
This {!parent} query can be combined with any other query and filter.
q=+BRAND_s:Nike +_query_:"{!parent which=type_s:parent}+COLOR_s:Red +SIZE_s:XL"
same can be achieved by employing filter query:
q={!parent which=type_s:parent}+COLOR_s:Red +SIZE_s:XL&fq=BRAND_s:Puma
Don’t try to constraint children by filter queries, it doesn’t work, because filter queries explicitly constraint {!parent} query.
{!child of=type_s:parent}BRAND_s:Puma returns SKUs belongs to the single Puma product.
Add block support for JSONLoader
https://issues.apache.org/jira/browse/SOLR-5183
Proposal for nested document support in Lucene
http://www.slideshare.net/MarkHarwood/proposal-for-nested-document-support-in-lucene
Other Parsers
https://cwiki.apache.org/confluence/display/solr/Other+Parsers
Block Join Query Parsers
In terms of performance, indexing the relationships between documents may be more efficient than attempting to do joins only at query time, since the relationships are already stored in the index and do not need to be computed.
To use these parsers, documents must be indexed as child documents. Currently documents can only be indexed with the relational structure with the XML update handler. The XML structure allows <doc> elements inside <doc> elements.
ou must also include a field that identifies the parent document as a parent; it can be any field that suits this purpose.
<add>
<doc>
<field name="id">1</field>
<field name="title">Solr adds block join support</field>
<field name="content_type">parentDocument</field>
<doc>
<field name="id">2</field>
<field name="comments">SolrCloud supports it too!</field>
</doc>
</doc>
<doc>
<field name="id">3</field>
<field name="title">Lucene and Solr 4.5 is out</field>
<field name="content_type">parentDocument</field>
<doc>
<field name="id">4</field>
<field name="comments">Lots of new features</field>
</doc>
</doc>
</add>
Block Join Children Query Parser
This parser takes a query that matches some parent documents and returns their children. The syntax for this parser is: q={!child of=<allParents>}<someParents>. The parameter allParents is a filter that matches only parent documents; here you would define the field and value that you used to identify a document as a parent. The parameter someParents identifies a query that will match some or all of the parent documents. The output is the children.
Using the example documents above, we can construct a query such as q={!child of="content_type:parentDocument"}title:lucene
Block Join Parent Query Parser
This parser takes a query that matches child documents and returns their parents. The syntax for this parser is similar: q={!parent which=<allParents>}<someChildren>. Again the parameter The parameter allParents is a filter that matches only parent documents; here you would define the field and value that you used to identify a document as a parent. The parameter someChildren is a query that matches some or all of the child documents. Note that the query for someChildren should match only child documents or you may get an exception.
Again using the example documents above, we can construct a query such as q={!parent which="content_type:parentDocument"}comments:SolrCloud.
Collapsing Query Parser
fq={!collapse field=<field_name>}
http://www.slideshare.net/lucenerevolution/grouping-and-joining-in-lucenesolr
Join Contrib
https://issues.apache.org/jira/browse/SOLR-4787
Solr(Cloud) should support block joins
https://issues.apache.org/jira/browse/SOLR-3076
Block Indexing / Join Improvements
https://issues.apache.org/jira/browse/SOLR-5142
Add scoring support for query time join
https://issues.apache.org/jira/browse/LUCENE-4043
Solr uses a different joining implementation. Which doesn't support mapping the scores from the `from` side to the `to` side. If you want to use the Lucene joining implementation you could wrap this in a Solr QParserPlugin extension.
No comments:
Post a Comment