加速Neo4j批量导入

时间:2015-12-03 16:21:21

标签: import neo4j

我正在尝试使用批量导入模块将数据导入Neo4j 2.2.5,但速度非常慢。我做错了什么?

我有3个单独的CSV文件,这些文件是来自SQL数据库的转储。最大的有2M +行。这是我的导入脚本:

//Load the messages
create index on :Mail(id);
import-cypher -d"\t" -i file:c:/messagesheaders.csv -b 10000 -q with distinct {mid} as mid merge (e:Mail {id: {mid}, date: {date}, message_id: {message_id}});

//Load recipients
create index on :Person(Email);
import-cypher -d"\t" -i file:c:/recipientsheaders.csv -b 10000 -q create (e:Person {Email: {rvalue}});

//Load senders
create index on :Person(Email);
import-cypher -d"\t" -i file:c:/messagesheaders.csv -b 10000 -q with distinct {sender} as sender merge (e:Person {Email: {sender}});

//Relationships between senders and mails
import-cypher -d"\t" -i file:c:/messagesheaders.csv -b 10000 -q match (e:Person {Email: {sender}}), (c:Mail {id: {mid}}) create (e)-[:HAS_SENT]->(c);

//Relationships between recipients and mails
import-cypher -d"\t" -i file:c:/recipientsheaders.csv -b 10000 -q match (e:Person {Email: {rvalue}}), (d:Mail {id: {mid}}) create (e)-[:HAS_RECEIVED {rtype: {rtype}}]->(d);

我可以很好地导入节点但是1小时后Neo4j仍然停留在第一组关系上。我怎样才能加快速度?

1 个答案:

答案 0 :(得分:0)

您是否查看了导入工具http://neo4j.com/docs/2.2.5/import-tool.html?它用于离线和初始创建数据库导入,应该快得多。