csv data format
The first column is the entity, the second column is the entity, and the third column is the relationship. After processing it into this format, place the csv file in the import folder of neo4j. Start importing below.
This is the case in the txt file: if there are double quotes, remove them.
Start the import operation below
Step 1: Delete all files
MATCH (n) DETACH DELETE (n)
Step 2: Import entity 1 (column 1)
load csv from "file:///a.csv" as line
create(:en{name:line[0]})
Step 3: Import entity 2 (column 2)
load csv from "file:///a.csv" as line
create(:en{name:line[1]})
Step 4: Entity deduplication
MATCH (n:en)
WITH n.name AS name, COLLECT(n) AS nodelist, COUNT(*) AS count
WHERE count > 1
CALL apoc.refactor.mergeNodes(nodelist) YIELD node
RETURN node
Step 5: Import relationship nodes
load csv from "file:///a.csv" as line
create(:rel{from:line[0],relation:line[2],to:line[1]})
Step 6: Import the relationship type
match (n:en),(r:rel),(m:en)
where n.name=r.from and m.name=r.to
create (n)-[:Reltion1{relation:r.relation}]->(m)
Other statements
//查询实体节点
match (n:en{name:"火绒安全"}),(r:rel),(m:en) where n.name=r.from and m.name=r.to return n
//删除全部关系类型
MATCH (n:en)-[r:Reltion]-(m:en)
DELETE r
//查询忽略大小写
MATCH (n:en) WHERE n.name =~ '(?i)php' RETURN n
//模糊查询
MATCH (n:en) WHERE n.name =~ '.*内容.*' RETURN n