Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-03-2021 08:34 AM
Hi all,
I'm struggling for days on a strategy for bulk creation of relationships on existing nodes. I have a set of nodes already in Neo4j and an external base of relationships in a dict (or dataframe):
{('A', 'B'): {
'sim1': 0.2943630213889271,
'sim2': 0.4710701248095422,
'sim3': 0.5337783469032883,
'composed_sim': 0.45043293483711544},
That is, the key is a tuple of the nodes to be related and sim1, sim2,..., are properties for this relation.
I can merge this relationships flawlessly iterating in a for loop with apoc.merge.relationship
, however, for millions of relationships, this strategy is unfeasible.
I've been reading about apoc.periodic.iterate() but I got confused about how this kind of external data is supposed to be loaded (my Neo4j instance runs on a remote container and I'm using py2neo to interact with it) and how to build the mappings for the batch operation.
Could someone please clarify how can I use apoc to accomplish this bulk relationship creation?
Thanks in advance.
06-03-2021 09:09 AM
Hi,
I've recently had some success merging large batches of nodes and relationships using this batch method very well summarized by @michael.hunger .
Basically, you can parse both matching criteria and new nodes/relationships with their properties into a JSON-style large string and send it as a parameter of a single cypher statement. I use the process in combination of Python for automation and parallelization, which works really nicely. Let me know if you need more help on this.
06-03-2021 03:57 PM
I still don't get it.
Do you mean that I should apply apoc.map() to my dictionary and then use apoc.iterate()?
All the sessions of the conference are now available online