title: Best way to batch insert using cypher in java code
body: <p>I'm not sure if this has been answered already but here goes.
  I have a Neoj DB already populated with lets say 100k nodes labelled as Person.
  I want to import activities that these persons have created and label them Activity.
  I have a csv of about 10 million activities which I would like to import into Neo4j. </p>
  
  <p>The code below is what I do to create Cypher statements that can look up a user that is associated with an activity, create the activity node and establish a relationship between the user and the activity.</p>
  
  <p>The method to handle this is below</p>
  
  <pre><code>public void addActivityToGraph(List&lt;String&gt; activities) {
  
      Map&lt;String, Object&gt; params = new HashMap&lt;&gt;();
  
      for (String r : activities) {
          String[] rd = r.split(";");
          log.info("Row count: " + (rowCount + 1) + "| " + r);
          log.info("Row count: " + (rowCount + 1)
                  + "| Array Length: " + rd.length);
  
          Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();
  
          props.put("activityid", Long.parseLong(rd[0]));
          props.put("objecttype", Integer.parseInt(rd[1]));
          props.put("objectid", Integer.parseInt(rd[2]));
          props.put("containertype", Integer.parseInt(rd[3]));
          props.put("containerid", Integer.parseInt(rd[4]));
          props.put("activitytype", Integer.parseInt(rd[5]));
          props.put("creationdate", Long.parseLong(rd[7]));
  
          params.put("props", props);
          params.put("userid", Integer.parseInt(rd[6]));
  
          try (Transaction tx = gd.beginTx()) {
             //engine is RestCypherQueryEngine
              engine.query("match (p:Person{userid:{userid}}) create unique (p)-[:created]-&gt;(a:Activity{props})", params);
  
              params.clear();
              tx.success();
  
          }
      }
  
  }
  </code></pre>
  
  <p>While this works, I'm sure I am not using the right mix of tools as this process takes a whole day to finish. There has to be an easier way. I see a lot of documentation with Batch Rest API but I've not seen any with the case I have here (find an already existing user, create a relationship between the user and a new activity)
  I appreciate all the help i can get here.</p>
  
  <p>Thanks.</p>