Solr 加入“未加入"子选择 [英] Solr join "not in" subselect
本文介绍了Solr 加入“未加入"子选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Solr 加入文档 Solr Join 中他们说:
In the Solr join documentation Solr Join they say that:
/solr/collection1/select ? fl=xxx,yyy & q={!join from=inner_id to=outer_id}zzz:vvv
相当于:
SELECT xxx, yyy
FROM collection1
WHERE outer_id IN (SELECT inner_id FROM collection1 where zzz = "vvv")
我如何在 Solr 中编写代码(请参阅 NOT):
How do I write in Solr (see the NOT):
SELECT xxx, yyy
FROM collection1
WHERE outer_id NOT IN (SELECT inner_id FROM collection1 where zzz = "vvv")
让我们考虑以下示例:
人物记录:
Lets consider the following example:
People Records:
1. name='a', id=1, teacherId=4
2. name='b', id=2, teacherId=4
3. name='c', id=3, teacherId=1
4. name='d', id=4, isTeacher='true'
现在我想选择他们的teacherId指向非教师ID的所有学生(记录#3).
在 SQL 中:
Now I want to select all students which their teacherId points to non teacher ID (record #3).
In SQL:
select * from people where teacherId not in (select id where isTeacher='true').
推荐答案
请尝试将-"放在整个连接过滤器之外,如下所示:
Please try put "-" outside of the whole join filter, like below:
/solr/collection1/select ?fl=xxx,yyy &q=-({!join from=inner_id to=outer_id}zzz:vvv)
/solr/collection1/select ? fl=xxx,yyy & q=-({!join from=inner_id to=outer_id}zzz:vvv)
这篇关于Solr 加入“未加入"子选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文