如何使用SOLR自行加入集合并具有其他条件

时间:2016-05-11 18:34:25

标签: solr

请参阅以下文档:https://wiki.apache.org/solr/Join

根据文档,SOLR等效于此SQL查询:

SELECT xxx, yyy
FROM collection1
WHERE outer_id IN (SELECT inner_id FROM collection1 where zzz = "vvv")

就是这样:

/solr/collection1/select ? fl=xxx,yyy & q={!join from=inner_id to=outer_id}zzz:vvv

基本上,我想做的SQL等同于:

SELECT xxx, yyy
FROM collection1
WHERE (aaa = "1" OR bbb = "2")
    OR outer_id IN (SELECT inner_id FROM collection1 where zzz = "vvv")

是否可以在SOLR中执行此查询?

1 个答案:

答案 0 :(得分:1)

您的查询应该是

fl=xxx,yyy&q=(aaa:1 bbb:2) {!join from=inner_id to=outer_id}zzz:vvv

应解释为(aaa:1 OR bbb:2) OR {!join from=inner_id to=outer_id}zzz:vvv