this is the 1st time I'm using APOC.
I'm trying the below query with APOC but experiencing some errors.
I'd really appreciate help fixing/organizing my query.
Note: without the use of APOC, all works fine.
call apoc.periodic.iterate(
"MATCH (s1:s) WITH s1 MATCH (e1:e) WHERE s1.id = 'OG.O.CL-2.0.0.0.21.13.1' AND e1.id = 'Corporate' MERGE (s1)-[r:POLICY_TO_TAG]->(e1)",
"ON MATCH SET r.id='56482bc3-9f40-4873-a5c6-b9294e14e8dc', r.name=null RETURN r.id as id, type(r) as type, s1 as startnode, e1 as endnode, labels(s1) as startlabel, labels(e1) as endlabel, r.name as name",
{batchSize:10000, parallel:true})
CALL apoc.periodic.iterate(
"MATCH (s1:s)
MATCH (e1:e)
WHERE s1.id = 'OG.O.CL-2.0.0.0.21.13.1' AND e1.id = 'Corporate'
RETURN s1, e1",
"MERGE (s1)-[r:POLICY_TO_TAG]->(e1)
ON MATCH SET r.id='56482bc3-9f40-4873-a5c6-b9294e14e8dc', r.name=null",
{batchSize:10000, parallel:true})
If there is no previous POLICY_TO_TAG relation between s1 and e1 nodes, there will be no insertion due to ON MATCH SET clause. Maybe you should add ON CREATE SET clause to cover that case. Some thing like this:
CALL apoc.periodic.iterate(
"MATCH (s1:s)
MATCH (e1:e)
WHERE s1.id = 'OG.O.CL-2.0.0.0.21.13.1' AND e1.id = 'Corporate'
RETURN s1, e1",
"MERGE (s1)-[r:POLICY_TO_TAG]->(e1)
ON MATCH SET r.id='56482bc3-9f40-4873-a5c6-b9294e14e8dc', r.name=null
ON CREATE SET r.id='56482bc3-9f40-4873-a5c6-b9294e14e8dc', r.name=nul",
{batchSize:10000, parallel:true})