cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

how to merge relationships on bulk data on existing nodes without creating new nodes

Anisha1
Node

how to merge relationships on bulk data on existing nodes without creating new nodes in neo4j as well as using py2neo on 10 lakh data.Any suggestions?
Attached the sample data.

6 REPLIES 6

Apoc has a suite of procedures for refactoring. One is merging relationships.  Maybe this will help. 

https://neo4j.com/labs/apoc/4.1/graph-updates/graph-refactoring/

https://neo4j.com/labs/apoc/4.1/overview/apoc.refactor/apoc.refactor.mergeRelationships/

Thank you for the response, but my doubt is regarding the data attached, how do I create relations for different type of devices present.
Ex, hierarchy is  Equipment->Card-> Port
Now all of them have their properties(device names, resource type, parent resource type , parent resource id, etc)
After creating the nodes and properties of equipment, port and card separately, how do I create relationship amongst such huge data of 1 million records.? Any examples to support?

 

ameyasoft
Graph Maven

From your sample data, which columns correspond to Equipment, Card, and Port nodes?

"A_ RESOURCE_TYPE" column   has the difference resource types, with respective parent resource type and ids.

Which version of Neo4j are you using?

Does each row represent a single entity (node)?  If so, does the A_RESOURCE_ID represent the unique id for the node?  Does the A_PARENT_RESOURCE_ID represent the node's parent's A_RESOURCE_ID?  Does a node with a blank A_PARENT_RESOURCE_ID must represent a root node, i.e. does not have a parent. If you answer yes to each of these questions, then you can you can use this spreadsheet to create the relationships after you have created the nodes in a previous script. The script would look something like the following:

load csv with headers from "file:///relationships.csv" as row
match(child:Resource{resource_id: $row.A_RESOURCE_ID})
match(parent:Resource{resource_id: $row.A_PARENT_RESOURCE_ID})
merge(child)-[:HAS_PARENT]->(parent)

Does this help?