anybody can help me with
MATCH(n:Customer)-[r:ORDERS]->(o:Order)<-[r1:ORDERS]-(n1:Customer)
WITH COLLECT(n)+COLLECT(n1) as nodes
CALL apoc.refactor.mergeNodes(nodes,{mergeRels:true}) YIELD node
RETURN node
I actually want to combine n and n1 because let's say n has "name" property and n2 has "email" property. I tried the code above and it says: "Neo.ClientError.Schema.ConstraintValidationFailed" with explanation: "Cannot delete node<1397>, because it still has relationships. To delete this node, you must first delete its relationships."
I've found the solution:
//SOLUTION
MATCH(n:Customer)-[r:ORDERS]->(o:Order)<-[r1:ORDERS]-(n1:Customer)
WITH o.order_id as i, HEAD(COLLECT([n,n1])) AS nodes
CALL apoc.refactor.mergeNodes(nodes, {mergeRels:true})
YIELD node
RETURN node
it works perfectly to all nodes referred as n and n1