Question: How to access Node/ Node properties within multiple nested apoc.periodic.iterator (s) ?
to create sample data:
:params eventParam=> [{eid: "e1"},{eid: "e2"}];
Query:
call apoc.periodic.iterate(
'
// create some nodes - *ideally these nodes will be read from some jdbc source*
UNWIND [1, 2, 3] AS gid
MERGE (f:FromNode {gid: gid} ) return f
',
'
// Run a nested apo.periodic.iterator - procedure to create relationship (FromNode)-[Related]->(Event) - 1 to n relationship
call apoc.periodic.iterate(
" unwind $events as ev return ev " , // *ideally events will be derived from (f)'s property
" merge (f)-[:RELATED_TO]->(e:Event {eid:ev.eid} ) return e ",
{params:{events: $events}}
) yield batches return batches
// Note there may be more iterators inside
//call apoc.periodic.iterate(
// " unwind $alerts as alert return alert " ,
// " merge (f)-[:HAS]->(a:Alert{..} ) return a ",
// {params:{alerts: $alerts}}
// ) yield batches return batches
',
{params:{events:$eventParam}, parallel:true}
)
Actual Output:
Expected Output:
Issue is: FromNode created in first cypherIterator is not accessible in nested iterator while creating relationship