如果您必须能够使用Neo4j 2.1.0-M01(尚未在产品中使用它!),您可以从新功能中受益.如果您要像这样创建/生成CSV文件:
val1,val2,val3
a_value,another_value,yet_another_value
a,b,c
....
您只需要启动以下代码:
final GraphDatabaseService graphDB = new RestGraphDatabase("http://server:7474/db/data/");
final RestAPI restAPI = ((RestGraphDatabase) graphDB).getRestAPI();
final RestCypherQueryEngine engine = new RestCypherQueryEngine(restAPI);
final String filePath = "file://C:/your_file_path.csv";
engine.query("USING PERIODIC COMMIT 500 LOAD CSV WITH HEADERS FROM '" + filePath
+ "' AS csv MERGE (a{main:csv.val1,prop2:csv.val2}) MERGE (b{main:csv.val3})"
+ " CREATE UNIQUE (a)-[r:relationshipname]->(b);", null);
您必须确保可以从安装服务器的计算机上访问该文件.
看一下在服务器上为您完成的my server plugin.如果构建此文件并将其放入plugins文件夹,则可以按以下方式使用j