1. 导入关系点
load csv from 'file:///M1-CVE-2015-5122_windows_h1_edge_edge_bind_no_header.csv' as line
create (:bind {source:line[0],target:line[1],parentGraph:'M1',sonGraph:'h1'})
注:若关系之间的source或者target点不存在时,先导入节点,如
load csv from 'file:///M1-CVE-2015-5122_windows_h1_edge_edge_connected_session_no_header.csv' as line
create (:process {name:line[0],parentGraph:'M1',sonGraph:'h1'})
导入完节点以后,需要进行去重操作,删除重复节点
MATCH (p:process {parentGraph:'M1',sonGraph:'h1'})
WITH p.name AS name, collect(p) AS nodes
WHERE size(nodes) > 1
FOREACH (node IN tail(nodes) | DELETE node)
2. 创建关系
MATCH (n:session {parentGraph:'M1',sonGraph:'h1'}),(m:bind {parentGraph:'M1',sonGraph:'h1'}),(s:process{parentGraph:'M1',sonGraph:'h1'})
where n.name=m.source and m.target=s.name
create (n)-[r:bind]->(s)
3. 删除关系点
这是中间文件,不需要保存
MATCH (n:bind)
DETACH DELETE n
4. 添加边的属性
LOAD CSV FROM 'file:///M1-CVE-2015-5122_windows_h1_edge_edge_bind_no_header.csv' AS line
MATCH (session {name: line[0]})-[r]->(process {name: line[1]})
SET r.capacity = line[2],r.ip = line[3],r.key= line[4],r.label = line[5],r.port = line[6] ,r.timestamp = line[7]
return r,session,process
5. 查询关系
LOAD CSV FROM 'file:///M1-CVE-2015-5122_windows_h1_edge_edge_bind_no_header.csv' AS line
MATCH (session {name: line[0]})-[r]->(process {name: line[1]})
return r,session,process
6. 删除关系
MATCH ()-[r:bind]->()
DELETE r
7. 补充
需要导入的csv放在neo4j的import目录下就是默认的file目录