Using inner Join in Solr query

15,328

I believe you are looking for something like this:

SQL:

SELECT * 
FROM books 
WHERE id IN (SELECT bookId 
             FROM bookauthors 
             WHERE authorId IN (SELECT authorId 
                                FROM author 
                                WHERE author.name LIKE '%Rowling%'))

Solr (split to multiple lines for readabilty):

http://<code>hostname:8983/solr/select?q=*:*&fq= 
{!join+from=bookId+to=id}
authorId:{!join+from=authorId+to=authorId}
author.name:Rowling

The key is to pass in the next join query after : instead of passing the value. For more information refer to this

Share:
15,328

Related videos on Youtube

Tam Thai
Author by

Tam Thai

Updated on September 14, 2022

Comments

  • Tam Thai
    Tam Thai over 1 year

    In SQL, I have the query like this

    SELECT * 
    FROM table1 INNER JOIN table2 ON 
         table1.table1To2Id = table2.table2Id INNER JOIN 
         table3 ON table1.table1To3Id = table3.table3Id
    

    How can I make the same query using Solr? Given that the field in SQL is the same field in Solr
    Thank in advance

  • Dinesh
    Dinesh about 6 years
    +1 The reference you cited only has a few more examples, but no definitive guide. Is there some other place to find Solr manuals, esp. for more complex features? Thanks
  • user3166881
    user3166881 over 4 years
    Is it possible to update the documentation? Link no longer works
  • Java Developer
    Java Developer over 4 years
    @user3166881, Thanks! Updated the link.