I want to copy multiple nodes and then delete the old ones simultaneously. I wrote a multithread java application for this purpose. My cypher query is as below:
String cypher= "MATCH (a:Person {surname:\""+ Thread.currentThread().getName()+"\"})
create (b:Person)
set b.surname=a.surname
SET b.version = '2'
WITH a,b
MATCH (a)-[r:has_indication]->(c)
WITH COLLECT(r) AS rels, a, b, c
FOREACH (rel in rels |
CREATE (b)-[r2:has_indication]->(c)
SET r2+=rel
)
with a,b,c
MATCH (c)-[r3:has_indication]->(a)
WITH COLLECT(r3) AS rels2, a, b, c
FOREACH (rel in rels2 |
CREATE (c)-[r3:has_indication]->(b)
SET r3+=rel
)
DETACH DELETE a " ;
and my java code is as below :
public void run() {
Driver driver = GraphDatabase.driver(
"bolt://localhost:7687", AuthTokens.basic("neo4j", "neo4j"));
Session session = driver.session();
session.runAsync( cypher);
}
I use 3 thread , when the three nodes have relation with each other only one node get updated but when these node don't have relation with each other , all the three nodes got updated successfully. How can I update them even when they have relation with each other simultaneously? I am using neo4j enterprise version 3.4.7 .