11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

With this alternative document model, all of the same queries demonstrated above can still be executed, simply<br />

by changing the " from" param to replace the " in_edge" field with the " id" field:<br />

http://localhost:8983/solr/alt_graph/query?fl=id&q={!graph+from=id+to=out_edge+maxDe<br />

pth=1}foo:[*+TO+10]<br />

...<br />

"response":{"numFound":6,"start":0,"docs":[<br />

{ "id":"A" },<br />

{ "id":"B" },<br />

{ "id":"C" },<br />

{ "id":"D" },<br />

{ "id":"G" },<br />

{ "id":"H" } ]<br />

}<br />

Join Query Parser<br />

JoinQParser extends the QParserPlugin. It allows normalizing relationships between documents with a join<br />

operation. This is different from the concept of a join in a relational database because no information is being<br />

truly joined. An appropriate SQL analogy would be an "inner query".<br />

Examples:<br />

Find all products containing the word "ipod", join them against manufacturer docs and return the list of<br />

manufacturers:<br />

{!join from=manu_id_s to=id}ipod<br />

Find all manufacturer docs named "belkin", join them against product docs, and filter the list to only products with<br />

a price less than $12:<br />

q = {!join from=id to=manu_id_s}compName_s:Belkin<br />

fq = price:[* TO 12]<br />

The join operation is done on a term basis, so the "from" and "to" fields must use compatible field types. For<br />

example: joining between a StrField and a TrieIntField will not work, likewise joining between a StrFiel<br />

d and a TextField that uses LowerCaseFilterFactory will only work for values that are already lower<br />

cased in the string field.<br />

Scoring<br />

You can optionally use the score parameter to return scores of the subordinate query. The values to use for this<br />

parameter define the type of aggregation, which are avg (average), max (maximum), min (minimum) total, or<br />

none.<br />

Joining Across Collections<br />

You can also specify a fromIndex parameter to join with a field from another core or collection. If running in<br />

<strong>Solr</strong>Cloud mode, then the collection specified in the fromIndex parameter must have a single shard and a<br />

replica on all <strong>Solr</strong> nodes where the collection you're joining to has a replica.<br />

Let's consider an example where you want to use a <strong>Solr</strong> join query to filter movies by directors that have won an<br />

Oscar. Specifically, imagine we have two collections with the following fields:<br />

movies: id, title, director_id, ...<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

287

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!