Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-07-2021 06:01 AM
HI, I need to reverse the relation on 10 million objects what the script should look like using apoc.periodic.iterate
<MATCH (n:Reservation)-[rel:has]->(p:Person) CALL apoc.refactor.invert(rel) yield input, output RETURN input, output/>
Important! I use Neo4j server version: 3.6
Solved! Go to Solution.
09-13-2021 02:06 PM
Thanks @Bennu
We used below code:
CALL apoc.periodic.iterate(
"MATCH (n:Reservation)-[rel:has]->(p:Person) return rel",
"UNWIND $_batch AS item CALL apoc.refactor.invert(item.rel) YIELD input, output RETURN input, output",
{batchMode: "BATCH_SINGLE", batchSize: 1000}
)
YIELD batches, operations
RETURN batches, operations AS total
09-08-2021 03:44 AM
Hi @Slawomir_Jaros !
I do like periodic commit a bit more.
CALL apoc.periodic.commit(
"MATCH (n:Reservation)-[rel:has]->(p:Person)
WITH rel limit $limit
CALL apoc.refactor.invert(rel) yield input, output
RETURN count(*)",
{limit:10000});
Tuning on limit according to the max heap on your server.
Lemme know how it goes.
Bennu
09-13-2021 02:06 PM
Thanks @Bennu
We used below code:
CALL apoc.periodic.iterate(
"MATCH (n:Reservation)-[rel:has]->(p:Person) return rel",
"UNWIND $_batch AS item CALL apoc.refactor.invert(item.rel) YIELD input, output RETURN input, output",
{batchMode: "BATCH_SINGLE", batchSize: 1000}
)
YIELD batches, operations
RETURN batches, operations AS total
All the sessions of the conference are now available online