neo4j 默认 utf-8 编码, 因此将 node/ 和 relations/ 下的所有文件用记事本编辑, 另存为 utf-8 编码。
首先要创建索引, 不然导入关系太慢。
CREATE INDEX FOR(n:Category) ON (n.name);
CREATE INDEX FOR (n:Check) ON (n.name);
CREATE INDEX FOR (n:Cureway) ON (n.name);
CREATE INDEX FOR (n:Department) ON (n.name);
CREATE INDEX FOR (n:Disease) ON (n.name);
CREATE INDEX FOR (n:Dishes) ON (n.name);
CREATE INDEX FOR (n:Drug) ON (n.name);
CREATE INDEX FOR (n:Food) ON (n.name);
CREATE INDEX FOR (n:Symptom) ON (n.name);
之后导入所有关系即可。
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_ACOMPANY.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Disease {name: row.to})
MERGE (m)-[:DISEASE_ACOMPANY]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_CATEGORY.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Category {name: row.to})
MERGE (m)-[:DISEASE_CATEGORY]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_CHECK.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Check {name: row.to})
MERGE (m)-[:DISEASE_CHECK]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_CUREWAY.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Cureway {name: row.to})
MERGE (m)-[:DISEASE_CUREWAY]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_DEPARTMENT.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Department {name: row.to})
MERGE (m)-[:DISEASE_DEPARTMENT]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_DISHES.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Dishes {name: row.to})
MERGE (m)-[:DISEASE_DISHES]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_DO_EAT.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Food {name: row.to})
MERGE (m)-[:DISEASE_DO_EAT]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_DRUG.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Drug {name: row.to})
MERGE (m)-[:DISEASE_DRUG]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_NOT_EAT.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Food {name: row.to})
MERGE (m)-[:DISEASE_NOT_EAT]->(n);
LOAD CSV WITH HEADERS FROM 'file:///doctor/relations/DISEASE_SYMPTOM.csv' AS row
MATCH (m:Disease {name: row.from}), (n:Symptom {name: row.to})
MERGE (m)-[:DISEASE_SYMPTOM]->(n);