Problems importing relationships

cypher
csv

(Claudiofrancesconi) #1

Hello i have Neo 1.1.12 on Mac OSX
with Neo Browser 3.4.9
i have a problem when i import a CSV for relationships within 2 nodes types: USER(user_id, user_name) and PAGE(page_id,page_name)

the command is:
USING PERIODIC COMMIT 500
load csv with headers from "http://127.0.0.1/NEO/neo-likes.csv" as line
MATCH (a:USER{user_id: line.user})
MATCH (b:PAGE{page_id: line.page})
CREATE (a)-[:LIKES]->(b)

but unfortunately only a part of relationships from the CSV are executed (around 27k on 220k total)
i don't understand where's the problem... is there any log of errors?
cheers


(M. David Allen) #2

Your syntax looks ok. This is most likely caused by failing to MATCH a user or a page by that data from the CSV.

Is it possible that the CSV is mentioning users and pages that aren't already in your database?

If you switch from MATCH to MERGE, it will always succeed and create the relationships that you expect, but may end up creating the new USER and PAGE nodes that are missing. If that's OK, that's a way to go. Otherwise look deeper at individual lines that are failing to match, and see what you find from there.


(Claudiofrancesconi) #3

excuse me
how would it be the syntax with merge?


(M. David Allen) #4

Just change each match to merge. That's all.

USING PERIODIC COMMIT 500
load csv with headers from "http://127.0.0.1/NEO/neo-likes.csv" as line
MERGE (a:USER{user_id: line.user})
MERGE (b:PAGE{page_id: line.page})
CREATE (a)-[:LIKES]->(b)

(Claudiofrancesconi) #5

ok thank you. i will try it, it's gonna take more than 1 hour


(M. David Allen) #6

Make sure to create indexes on those ID fields like this, it will drastically speed up the merges.

CREATE INDEX ON :USER(user_id);
CREATE INDEX ON :PAGE(page_id);

(Claudiofrancesconi) #7

ok thanks.
but something keeps not working
just imported me 35k relationships on 240k


(Claudiofrancesconi) #8

iby the way
it seems i can add only 1 index... after i add the first the second statement return me a (no changes, no records)


(Claudiofrancesconi) #9

probably the problem was the ";" now i created the double index and re-imported the relationships very quickly but... only 26K of them...
don't understand whats wrong