Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-13-2018 02:42 AM
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
11-13-2018 05:13 AM
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.
11-13-2018 05:18 AM
excuse me
how would it be the syntax with merge?
11-13-2018 05:39 AM
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)
11-13-2018 05:42 AM
ok thank you. i will try it, it's gonna take more than 1 hour
11-13-2018 06:55 AM
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);
11-13-2018 07:46 AM
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)
11-13-2018 11:28 AM
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
02-03-2019 03:43 PM
Most likely is that you have missing matches for your nodes.
for these:
MERGE (a:USER{user_id: line.user})
MERGE (b:PAGE{page_id: line.page})
You can check with:
load csv with headers from "http://127.0.0.1/NEO/neo-likes.csv" as line
OPTIONAL MATCH (a:USER{user_id: line.user})
OPTIONAL MATCH (b:PAGE{page_id: line.page})
WITH * WHERE a is null or b is null
RETURN line LIMIT 100
11-13-2018 07:07 AM
ok thanks.
but something keeps not working
just imported me 35k relationships on 240k
All the sessions of the conference are now available online