Neo4j has a batch insertion mode intended for initial imports, which must run in a single thread and bypasses transactions and other checks in favor of performance. Indexing during batch insertion is done using BatchInserterIndex which are provided via BatchInserterIndexProvider. An example:
BatchInserter inserter = new BatchInserterImpl( "target/neo4jdb-batchinsert" ); BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider( inserter ); BatchInserterIndex actors = indexProvider.nodeIndex( "actors", MapUtil.stringMap( "type", "exact" ) ); actors.setCacheCapacity( "name", 100000 ); Map<String, Object> properties = MapUtil.map( "name", "Keanu Reeves" ); long node = inserter.createNode( properties ); actors.add( node, properties ); // Make sure to shut down the index provider indexProvider.shutdown(); inserter.shutdown();
The configuration parameters are the same as mentioned in Section 7.10, “Configuration and fulltext indexes”.
Here are some pointers to get the most performance out of BatchInserterIndex
:
Copyright © 2011 Neo Technology