I'm trying to delete an entire list starting from a given node to the end of the list.
Where is the list of the root,relationship and child nodes. The child nodes can have an undetermined nodes.
(r:Root {name:'masterDoc'})<-[p:previous]<-(s1:schema)<-[p1:previous]<-(s2:schema)<-[pn:previous]<-(sn:Schema)
When I run the cypher query below I'm getting a Type mismatch: expected Node, Path or Relationship but was Collection
MATCH (n:`Root` {name:'masterDoc'})-[r:previous*]-(s) delete s,r,n
Any Idea?
You want to pull out the longest path of nodes, iterate over the relationships and delete each one and then iterate over the nodes and delete them.
NOTE: This assumes that each node in the path is no longer anchored to anything other than the nodes in the path otherwise they will not be able to be removed.