在Solr查询中使用内部连接

时间:2022-08-22 15:40:05

In SQL, I have the query like this

在SQL中,我有这样的查询

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

如何使用Solr进行相同的查询?鉴于SQL中的字段是Solr中的相同字段,请提前感谢

1 个解决方案

#1


4  

I believe you are looking for something like this:

我相信你正在寻找这样的东西:

SQL:

SQL:

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

Solr:

Solr的:

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

关键是在以下之后传入下一个连接查询:而不是传递值。有关更多信息,请参阅此内容

#1


4  

I believe you are looking for something like this:

我相信你正在寻找这样的东西:

SQL:

SQL:

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

Solr:

Solr的:

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

关键是在以下之后传入下一个连接查询:而不是传递值。有关更多信息,请参阅此内容