I'm stuck writing a Cypher query that would allow me to find all nodes which their code are NOT included in a given list. I've tried searching for pattern negation, node negation, exclude in path with no success.
Let's assume I have a list of codes (even though this list one has 1 element): ["1V2ZG"]
I'd like to build a Cypher query that would return every child of ARNOG node which is NOT in the above list.
This is the starting graph:
The graph response I want:
I'd like the query to return only the "ARNOG" node if the code list contains BOTH of its children ("Y6JPG", "1V2ZG") OR return No results
The query I'm using is returning all nodes which is not what I want:
MATCH (excl:Client)<-[:PARENT_OF*]-(n:Client:Group), path=(b:BaseHierarchy)-[:INCLUDES]->(n)-[:PARENT_OF*]->(inc:Client) WHERE excl.code IN ['1V2ZG'] AND n.code = 'ARNOG' WITH b, nodes(path) as nodes, relationships(path) as relationships RETURN b, apoc.coll.toSet(apoc.coll.flatten(collect(relationships))) as relationships, apoc.coll.toSet(apoc.coll.flatten(collect(nodes))) as nodes;