title: Inserting large number of nodes into Neo4J
body: <p>I have a table stored in a typical MySQL database and I've built a small parser tool using java, to parse out and build a neo4j database. This database will have ~40 million nodes, each with one or more edges (with a possible maximum of 10 edges). The problem comes from the way I have to create certain nodes. There's a user node, comment node, and hashtag node. The user nodes and hashtag nodes must each be unique. I'm using code from the following example to ensure uniqueness:</p>
  
  <pre><code>public Node getOrCreateUserWithUniqueFactory( String username, GraphDatabaseService graphDb )
  {
      UniqueFactory&lt;Node&gt; factory = new UniqueFactory.UniqueNodeFactory( graphDb, "users" )
      {
      @Override
      protected void initialize( Node created, Map&lt;String, Object&gt; properties )
      {
          created.setProperty( "name", properties.get( "name" ) );
      }
  };
  
  return factory.getOrCreate( "name", username );
  </code></pre>
  
  <p>}</p>
  
  <p>I have thought about using the batch inserter but I haven't seen a way to check if a node is unique while performing a batch insert. So my question is what is the fastest way to insert all these nodes while still ensuring that they retain their uniqueness. Any help would as always be greatly appreciated.</p>