No changes, no records - associating two nodes

Hi there,

I am trying to associate two nodes of the same kind/label. Companies are represented by nodes and the relationship is the association one company has to another i.e. Shareholder, Parent etc. I have simiplified my dataset down in order to get the correct cypher query before trying to create thousands of relationships.

I have successfully created two nodes through a csv load. 'CompanyABC' and 'CompanyXYZ' with their associated unique IDs. I also created an index on LegalEntityID.

The csv looks like the following;
LegalEntityID,LegalEntityName

225176,CompanyABC

12470,CompanyXYZ

(see below screenshot - there are no whitespaces at all)
csv

The cypher query I used to create the nodes is:

LOAD CSV WITH HEADERS FROM "file:///test.csv" AS csvLine

CREATE (e:Entity {Id: toInteger(csvLine.LegalEntityID), LegalEntityName: csvLine.LegalEntityName})

I then tried to associate these two nodes using the below;

Match (a:LegalEntityID),(b:LegalEntityID) where a.LegalEntityID = '225176' and b.LegalEntityID = '12470' create (b)-[r:HAS_ASSOCIATION]->(a)

I received the response: (no changes, no records)

I then tried the below;

MATCH (a:LegalEntityID{LegalEntityID:toInteger(225176)}),(b:LegalEntityID{LegalEntityID:toInteger(12470)})

CREATE (b)-[r:hasAssociation]->(a)

RETURN b,r,a

and I still got the response (no changes, no records) - see below screenshot

Please could you let me know where I am going wrong – I have tried everything!

Thanks and regards
Rebecca

Your LOAD CSV statement is creating nodes with a label named 'Entity`. For example your CREATE statement is

CREATE (e:Entity {Id: toInteger(csvLine.LegalEntityID), LegalEntityName: csvLine.LegalEntityName})

as such your MATCH statements should be on the Entity label and not the LegalEntity. So

MATCH (a:LegalEntityID{.... .....

should be replaced as

MATCH (a:Entity{ ... .....