当我在Neo4j shell中输入此查询时:
MATCH (b:PHARMA)-[r:HAS_DONATED]->(a:DOCTOR)
WITH a,r,b, r.DECL_AVANT_MONTANT as total, COUNT(r) as count
MERGE (b)-[:RELATIONSHIP {
totalDECL: total,
numberDECL: count
}]->(a);
我收到此消息:
Error occured in server thread; nested exception is: java.lang.OutOfMemoryError: Java heap space
如何解决这个问题?
答案 0 :(得分:2)
我使用此查询解决了我的问题:
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/sunshine.anonymes.csv" AS line
FIELDTERMINATOR ','
MATCH (b:DOCTOR {ID: line.BENEF_PS_ID})
MATCH (a:PHARMA {NAME: line.LABO})
MERGE (a)-[r:IS_LINKED_TO]->(b)
ON CREATE SET r.numberDECL = 1, r.totalDECL = toINT(line.DECL_AVANT_MONTANT)
ON MATCH SET r.numberDECL = r.numberDECL +1, r.totalDECL = line.totalDECL + r.totalDECL;
基本上,我在csv导入期间创建关系并在整个过程中更新属性。
感谢您的帮助!
答案 1 :(得分:1)
我不知道它是否有帮助。但是这里修复了Cypher查询您的案例:
MATCH (b:PHARMA)-[r:HAS_DONATED]->(a:DOCTOR)
WITH a, b, SUM(r.DECL_AVANT_MONTANT) as total, COUNT(r) as count
MERGE (b)-[:RELATIONSHIP {
totalDECL: total,
numberDECL: count
}]->(a);