You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2013/12/10 15:42:42 UTC

[Solr Wiki] Trivial Update of "Join" by AndyLester

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "Join" page has been changed by AndyLester:
https://wiki.apache.org/solr/Join?action=diff&rev1=14&rev2=15

Comment:
Fix some little typos

  <!> Solr4.0
  
  = Introduction =
- 
- In many cases, documents have relationships between them and it is too expensive to denormalize them.  Thus, a join operation is needed.  Preserving the document relationship allows documents to be updated independently without having to reindex large numbers of denormalized documents.  
+ In many cases, documents have relationships between them and it is too expensive to denormalize them.  Thus, a join operation is needed.  Preserving the document relationship allows documents to be updated independently without having to reindex large numbers of denormalized documents.
  
  = Input Parameters =
+ Joins are processed using Solr's LocalParams syntax.  The query typically looks like: {{{q={!join from=manu_id_s to=id}ipod}}}
  
- Joins are processed using Solr's LocalParams syntax.  The query typically looks like:
- {{{q={!join from=manu_id_s to=id}ipod}}}
- 
- Thus, you need the join !QueryParser(Plugin) which is specified by the {{{ {!join} }}} syntax.  Then, you need specify the foreign key relationship by giving the from and to fields to join on. 
+ Thus, you need the join !QueryParser(Plugin) which is specified by the {{{ {!join} }}} syntax.  Then, you specify the foreign key relationship by giving the from and to fields to join on.
  
  = Examples =
- 
  In the example data, all documents have a unique "id" field, but documents modeling products also have a "manu_id_s" which is essentially a "foreign key" to the "id" of the associated manufacturer doc.
  
-  * Find all product docs matching "ipod", then join them against (manufacturer) docs and return the list of manufactures that make those products
+  * Find all product docs matching "ipod", then join them against (manufacturer) docs and return the list of manufacturers that make those products
-    * http://localhost:8983/solr/select?q={!join+from=manu_id_s+to=id}ipod
+   * http://localhost:8983/solr/select?q={!join+from=manu_id_s+to=id}ipod
   * Find all manufacturer docs named "belkin", then join them against (product) docs and return the list of products produced by that manufacturer
-    * http://localhost:8983/solr/select?q={!join+from=id+to=manu_id_s}compName_s:Belkin
+   * http://localhost:8983/solr/select?q={!join+from=id+to=manu_id_s}compName_s:Belkin
   * Find all manufacturer docs named "belkin", then join them against (product) docs and filter that list to only products with a price less than 12 dollars
-    * http://localhost:8983/solr/select?q={!join+from=id+to=manu_id_s}compName_s:Belkin&fq=price:%5B%2A+TO+12%5D
+   * [[http://localhost:8983/solr/select?q={!join+from=id+to=manu_id_s}compName_s:Belkin&fq=price:[*+TO+12]|http://localhost:8983/solr/select?q={!join+from=id+to=manu_id_s}compName_s:Belkin&fq=price:%5B%2A+TO+12%5D]]
   * Find all products matching ipod (sorted by score) and filter that by the set of products produced by joining manufacturers named "Belkin" or "Apple"
-    * 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://localhost:8983/solr/select?q=ipod&fl=*,score&sort=score+desc&fq={!join+from=id+to=manu_id_s}compName_s:(Belkin%20Apple)|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]]
  
  = Compared To SQL =
- 
- For people who are used to SQL, it's important to note that Joins in Solr are not really equivalent to SQL Joins because no information about the table being joined "from" is carried forward into the final result.  A more appropriate SQL analogy would be an "inner query"
+ For people who are used to SQL, it's important to note that Joins in Solr are not really equivalent to SQL Joins because no information about the table being joined "from" is carried forward into the final result.  A more appropriate SQL analogy would be an "inner query".
  
  This Solr request...
  
  {{{
- /solr/collection1/select ? fl=xxx,yyy & q={!join from=inner_id to=outer_id}zzz:vvv 
+ /solr/collection1/select ? fl=xxx,yyy & q={!join from=inner_id to=outer_id}zzz:vvv
  }}}
- 
  Is comparable to this SQL statement...
  
  {{{
- SELECT xxx, yyy 
+ SELECT xxx, yyy
  FROM collection1
  WHERE outer_id IN (SELECT inner_id FROM collection1 where zzz = "vvv")
  }}}
- 
  = Limitations =
- 
   * Fields or other properties of the documents being joined "from" are not available for use in processing of the resulting set of "to" documents (ie: you can not return fields in the "from" documents as if they were a multivalued field on the "to" documents)
   * The Join query produces constant scores for all documents that match -- scores computed by the nested query for the "from" documents are not available to use in scoring the "to" documents
   * In a DistributedSearch environment, you can not Join across cores on multiple nodes.  If however you have a custom sharding approach, you could join across cores on the same node.
  
  = Quick Start =
- 
  /!\ '''NOTE:''' The described additions to the "browse" screen is currently dependent on [[https://issues.apache.org/jira/browse/SOLR-2502|SOLR-2502]]
  
   * Follow the Tutorial at http://lucene.apache.org/solr/tutorial.html to get setup