Hi there
I am trying to associate nodes of the same kind/label but struggling with the correct cypher. I have a list of companies and I am trying to associate them based on an association type i.e. Company ABC is a shareholder of Company XYZ etc.
My Node CSV looks like the following;
LegalEntityID,LegalEntityName,LegalEntitySubType
225176,Company ABC,Financial Institution
52489,Company XYZ,Commercial Corporate
And the cypher query used to create the nodes is;
LOAD CSV WITH HEADERS FROM "file:///Nodes.csv" AS csvLine
CREATE (e:Entity {Id: toInteger(csvLine.LegalEntityID), LegalEntityName: csvLine.LegalEntityName, LegalEntitySubType: csvLine.LegalEntitySubType})
My Relationship CSV looks like the following;
RelationshipID,LegalEntityID1,LegalEntityID2,AssociationType,HierarchyLevel
285378,52489,225176,Shareholder,1
The issue is that I do not know how to create a relationship between two nodes that are linked on the same ID (LegalEntityID) thus I know it is incorrect to have LegalEntityID1 and LegalEntityID2 in the relationship file but I am not sure how to associate the entities otherwise.
I tried the following cypher query however the response is "(no changes, no records)";
LOAD CSV WITH HEADERS FROM 'file:///Relationships.csv' AS csvLine
MATCH (e1:Entity {Id:csvLine.LegalEntityID1}), (e2:Entity {Id:csvLine.LegalEntityID2})
MERGE (e2)-[:Associated_to]->(e1)
Due to the large number of relationships, this needs to be one by loading a CSV.
Please assist if you are able to, any help would be much apprciated.
Thanks and regards
Rebecca