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.

Newbie issue on Importer: succeeding to import nodes but not relationship.

mosheco
Node

Hi,

I am new to Neo4j and Aura and am trying out the Importer on very simple data. I have two tables, Resident and City where the Resident has a column stating which city they live in. The CSV files are:

resident.csv:
Name,Age,city
Peter,61,New York City
Brian,42,New York City
Bill,46,San Francisco
John ,34,Chicago

city.csv:
Name,State
New York City,New York
San Francisco,California
Chicago,Illinois

When importing, the nodes import succesfully, but no relationships are created.

The code for creating the realtionships, as displayed by the Importer is:

UNWIND $relRecords AS relRecord
MATCH (source: `Resident` { `Name`: relRecord.`city` })
MATCH (target: `City` { `Name`: relRecord.`Name` })
MERGE (source)-[r: `Lives_in`]->(target);
I have attached a screenshot of the GUI defining the relationship.
What am I missing?
1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

I got it to work with the following settings.  Switch your 'from' and 'to' fields, to 'name' and 'city', respectively. What the settings are saying is that the linkage between the 'resident' and 'city' nodes is contained in the file 'residents' and the 'from' node should match on this file's (resident.csv) 'name' field and the 'to' node should match on this file's 'city' field. When it creates the query, it will look for a 'resident' node whose 'ID' field equals 'name' value and a 'city' node whose 'ID' field equals the 'city' value.  it is a little confusing because your file that contains the relationships between residents and cities is the residents file. Typically you may have a separate relationships file to import because you may have relationship properties in included in that data file. 

 

Screen Shot 2022-07-09 at 7.47.07 AM.png

View solution in original post

2 REPLIES 2

glilienfield
Ninja
Ninja

I got it to work with the following settings.  Switch your 'from' and 'to' fields, to 'name' and 'city', respectively. What the settings are saying is that the linkage between the 'resident' and 'city' nodes is contained in the file 'residents' and the 'from' node should match on this file's (resident.csv) 'name' field and the 'to' node should match on this file's 'city' field. When it creates the query, it will look for a 'resident' node whose 'ID' field equals 'name' value and a 'city' node whose 'ID' field equals the 'city' value.  it is a little confusing because your file that contains the relationships between residents and cities is the residents file. Typically you may have a separate relationships file to import because you may have relationship properties in included in that data file. 

 

Screen Shot 2022-07-09 at 7.47.07 AM.png

Thank you!

Yes, I managed to confuse myself 😀

Works perfectly now.