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
is equivalent to:
SELECT xxx, yyy
FROM collection1
WHERE outer_id IN (SELECT inner_id FROM collection1 where zzz = "vvv")
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'
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').
I'm faced with this problem too and that's how I resolved it:
q=-_query_:"{!join from=inner_id to=outer_id}zzz:vvv"
You can add this nested query to fq
too.
Hope that helps!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With