Reputation: 113
I'm using 2 cores and trying to get the results to depend on companyid using Join query, but I couldn't get the expected result.
first core : job (id,title,companyid)
second core : company (id,companyid,companyname)
expected result : title,companyid,companyname
This is the query I used.
http://localhost:8983/solr/job/select?q=*:*&fq={!join from=companyid to=companyid fromIndex=company}
Upvotes: 0
Views: 312
Reputation: 52792
JOINs in Solr aren't the same as joins as you're used to in regular databases. A join is not able to return fields from both sides of the join - i.e. it can only be used for filtering a result set by a value looked up on the other side of the join.
In your example you could return all company names that have a specific title, but you cannot return both title
and companyname
in the same response (by using the join functionality).
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".
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)
Don't think of storage in document databases in the same was for normalized databases. Instead, store the company name together with each document with the title - keeping everything in a single core instead of two. A core is not used as a direct replacement of a table.
Upvotes: 1