A bit of a Neo4j newbie and I've been working on a query that seems like it should be simple, yet I'm having problems figuring out the correct Cypher. Given the below model, I want to get all Objects
(and their Statuses
) that are replacements for obj1
that either have a Status type of 2
, or no Status
. My desired result is to return the ob3
node and it's Status
node in addition to the ob4
node.
So far, the closest I've come is:
match (obj1:Object{nm:'obj1'})-[:REPLACES*]->(repObj)
optional match p=(repObj)-[:HAS_STATUS]->(stat)
where stat.type = 2
return repObj, p
This returns my desired nodes but also returns the ob2
node without it's Status
node. If I keep the above query but only return the p
variable, I get the ob3
node and it's Status
, but do not get back the ob4
node. I've tried a combination of different queries including WITH
, NOT
and UNION
clauses but I feel like I'm missing something very simple.