1、需要通过cypher load加载文件直接生成对应的图谱数据,配置如下:
dbms.directories.import=import
dbms.security.allow_csv_import_from_file_urls=true
如何样例:
将文件放到neo4j目录下的import目录
然后执行:
LOAD CSV WITH HEADERS FROM "file:///test.csv" AS row
MERGE (parent_category:Category {name: row.parent_category})
MERGE (category:Category {name: row.category})
MERGE (category)-[:PARENT_CATEGORY]->(parent_category)
MERGE (p:Product {sku: toString(row.sku)})
SET p.name = row.name,
p.price = toFloat(row.price)
MERGE (p)-[:IN_CATEGORY]->(category)
MERGE (d:Designer {name: row.designer})
MERGE (p)-[:DESIGNED_BY]-(d)
RETURN *;