{
"identity": 7,
"labels": [
"Parent"
],
"properties": {
"name": "foo1"
}
}
{
"identity": 8,
"labels": [
"Child"
],
"properties": {
"name": "bar2"
}
}
{
"identity": 9,
"labels": [
"Child"
],
"properties": {
"name": "bar1"
}
}
{
"identity": 10,
"labels": [
"Parent"
],
"properties": {
"name": "foo2"
}
}
I want to select the Parents which do not have any child with name='abc'
Expected Behaviour : I should get both Parents ( foo1 and foo2 ) as result
Query1 :
Match (x1:Parent) with x1
optional Match (x1)-[:CHILD]-(x2:Child) with x1 , collect(x2) as x3
UNWIND x3 as x2
WITH x1 , x2 , x3
where none (x IN x3 where x.name IN ['abc'])
return DISTINCT x1
This query is returning me only 1 Parent(foo1) but it should return both parents and 2nd parent( foo2 ) is not connected to any child.
PS : Reason for using UNWIND is to use the variables for further WHERE clauses on variable x2 .
Neo4j 4.1