In case you already have code for data import written against the normal Neo4j API, you could consider using a batch inserter exposing that API.
| Note | |
|---|---|
This will not perform as good as using the |
Also be aware of the following:
Transaction.finish()/close() or Transaction.success() will do nothing.
Transaction.failure() method will generate a NotInTransaction exception.
Node.delete() and Node.traverse() are not supported.
Relationship.delete() is not supported.
GraphDatabaseService.getRelationshipTypes(), getAllNodes() and getAllRelationships() are not supported.
With these precautions in mind, this is how to do it:
GraphDatabaseService batchDb =
BatchInserters.batchDatabase( "target/batchdb-example", fileSystem );
Label personLabel = DynamicLabel.label( "Person" );
Node mattiasNode = batchDb.createNode( personLabel );
mattiasNode.setProperty( "name", "Mattias" );
Node chrisNode = batchDb.createNode();
chrisNode.setProperty( "name", "Chris" );
chrisNode.addLabel( personLabel );
RelationshipType knows = DynamicRelationshipType.withName( "KNOWS" );
mattiasNode.createRelationshipTo( chrisNode, knows );
batchDb.shutdown();
| Tip | |
|---|---|
The source code of the example is found here: BatchInsertDocTest.java |
Copyright © 2014 Neo Technology