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.

Create Relationships between millions of Nodes

I have been trying to create relationships between many nodes. The nodes are Video nodes which include a username(user that uploaded the video) and user which also includes username as a property. I have been trying to figure out how to iteratively create a relationship between Video and User by the username. I want to create a relationship User-UPLOADS-Video.

I did try to create an index for the username property on the video username.

This is what I was trying to run, but only the nodes are imported and the relationships are not created. Is there something that I am missing or should include? If there is a better way to do this, please let me know. I am new to Neo4j and I am sure there is a better way to do it.

CALL apoc.periodic.iterate("
  CALL apoc.load.csv('user.csv',{
    mapping:{
      userID: {type:'string'},
      views: {type:'int'},
      friends: {type:'int'}
    }
  }) YIELD map as row RETURN row
"," 
  CREATE (u:User) SET u = row
  WITH u
  MATCH (v:Video)
  WHERE u.userID = v.user
CREATE (u)-[:UPLOADS]->(v)
", {batchSize:10000, parallel:false, iterateList:true});

  • Version 1.3.8 (1.3.8.34) desktop
    -plugins: APOC
1 REPLY 1

intouch_vivek
Graph Steward

@kaylie.lewis,

Kindly try below code:

   mapping:{
     userID: {type:'string'},
     views: {type:'int'},
     friends: {type:'int'}
   }
 }) YIELD map as row RETURN row
"," 
 CREATE (u:User) SET u = row
 WITH u
 MATCH (v:Video)
 WHERE u.userID = v.user
With u,v
CREATE (u)-[:UPLOADS]->(v)
", {batchSize:10000, parallel:false, iterateList:true});```