Hi all, I have a cypher query that I am struggling to get to work correctly.
Basically I have a graph loaded to my db. I then need to be able to run a query to remove any nodes and edges that are not either directly related to to one or more node names supplied to the query or any descendant nodes in a recurring fashion.
Now my query might receive the name of one or more nodes.
I have the following query so far;
//Set graph to multiple entities
MATCH (parent:EntityProcess)
WHERE NOT EXISTS {
MATCH (parent)-[:PARENT_OF*0..]->(entity:EntityProcess)
WHERE entity.name IN ["EYU", "Member", "Organisation"]
}
DETACH DELETE parent
Now looking at my query what I am trying to achieve is to remove everything that has no PARENT_OF relationship of either "EYU", "Member" or "Organisation" or anything that has a PARENT_OF relationship related to any of those nodes. So I want to keep everything related to "EYU" and all of it's relationships and everything related to all of those relationships etc, and the same applies to "Member" and "Organisation".
If I only use a single node name then my query works as expected.
If I use multiple names, as above, then I am only getting expected results for the first one.
I am clearly missing something and I am assuming it is some sort of iteration issue with the way I think "IN" works in Cypher and maybe confusing it with TSQL, but then I am very confused at the best of times!
Did I explain this well enough? Can you understand what I am trying to achieve?