Database Reference
In-Depth Information
//Neo4j Database should be located at following path
<$NEO4J_HOME>/data/graph.db
BatchInserter inserter = BatchInserters.inserter(
"graph.db" );
//Creating Object of Index Providers
BatchInserterIndexProviderindexProvider=new
LuceneBatchInserterIndexProvider( inserter );
Try{
//Getting reference of Index
BatchInserterIndex actors = indexProvider.nodeIndex(
"cinestars", MapUtil.stringMap( "type", "exact" ) );
//Enabling Caching on Nodes
actors.setCacheCapacity( "name", 100000 );
//Creating Node and setting Properties
//"<>" or generics are available with Java>=1.5
// But it is recommended to use Java>=1.7 with Neo4j
API's
Map<String, Object> properties = MapUtil.map( "name",
"Keanu Reeves" );
long node = inserter.createNode( properties );
//Adding Node to Index
actors.add( node, properties );
//make the changes visible for reading, use
Carefully, requires IO!
actors.flush();
// Shut down the index provider and inserter
} catch (Exception e) {
//Print Exception on Console and shutdown the
Inserter and Indexer
e.printStackTrace();
//Shutdown the Index and Inserter, so that your
database is not corrupted.
indexProvider.shutdown();
inserter.shutdown();
}
indexProvider.shutdown();
inserter.shutdown();
}
Search WWH ::




Custom Search