|
1. 先看下构建好的关系图谱如下: 
2. 构建节点,并且导入数据 create table ch_from_to_count( id int primary key auto_increment, fromWho VARCHAR(100), toWho varchar(100), caseId VARCHAR(24), countNum int(11) )charset utf8; 表中插入数据: insert into ch_from_to_count(fromWho,toWho,caseId,countNum) SELECT * from( SELECT DISTINCT fromWho,substring_index(substring_index(t.toWho,';', b.help_topic_id + 1), ';', -1) toWho ,caseId,countNum FROM ( SELECT DISTINCT * from from_to_count_2 ) t join mysql.help_topic b ON b.help_topic_id < (LENGTH(t.toWho) - LENGTH(REPLACE(t.toWho, ';', '')) + 1) ) a ---------------------------------------------------------------
3.neo4j数据导入ch_from_to_count节点: load csv with headers from 'file:///ch_from_to_count.csv' as line merge (a:ch_from_to_count { id:line.id, fromWho:line.fromWho, toWho:line.toWho, caseId:line.caseId, countNum:line.countNum}) return a.id as id, a.fromWho AS fromWho, a.toWho AS toWho, a.caseId AS caseId, a.countNum as countNum neo4j数据导入ch_toWho节点: load csv with headers from 'file:///ch_toWho.csv' as line merge (a:ch_toWho { from_id:line.from_id, toWho:line.toWho, to_id:line.to_id}) return a.from_id as from_id, a.toWho AS toWho, a.to_id as to_id
4. 导入关系数据 MATCH (f:fromWho),(t:toWho) where f.id=t.id CREATE (f)-[r:rel_b{caseId:f.caseId,countNum:f.countNum}]->(t) return r |