I have simple, large CSV file, with no headers, of the structure:
name1, name2
name3, name4
name2, name4
...
I'm trying to import it all to Neo4J and create the relationships at the same time. First I've added the constraint CREATE CONSTRAINT ON (u:User) ASSERT u.name IS UNIQUE
and then I ran:
USING PERIODIC COMMIT
LOAD CSV FROM '${file}' AS line
WITH line LIMIT 50000
MERGE (u:User {name: line[0]})-[:connected_to]->(q:User {name: line[1]})
The graph I get are just connected pairs. I cannot find a single node that has more than one relationship (even though many nodes appear many times in both the left and right columns). Also, I expected to see some clusters.
Clearly I'm doing something wrong with my insertion. I assume I can run down the file twice and create all nodes and then create all relationships, but I feel like I'm missing something simple that can do it all in one operation.
Correction: Had one of the property names as 'number' - they are both 'name'.
john
node with all of the others attached. I did addtrim()
to each name in the name matches so it would remove the leading spaces after the comma if indeed there are any. – Dave Bennett