我正在导入从关系数据库导出的 .CSV 文件。导入进展顺利,但是当我尝试使用分配的标签在创建的节点之间创建关系时,它正在为关系创建新节点,而不是使用现有标签。我已经为此绞尽脑汁三天了 - 有什么想法吗?
代码:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///seshatdata/sellable_unit_features.csv" AS line
WITH line, SPLIT(line.ship_dt, '-') AS date
CREATE (sellableunit:SellableUnit {sellable_unit_id: line.sellable_unit_id, sellable_unit_nm: line.sellable_unit_nm, sellable_unit_version_id: line.sellable_unit_version_id})
MERGE (feature:Feature {Feature_id:line.feature_id, feature_nm: line.feature_nm})
CREATE (SellableUnit)-[r:CONTAINS]->(Feature)
SET r.start_year = TOINT(date[0]);
显然,CREATE (SellableUnit)-[r:CONTAINS]->(Feature)
行是罪魁祸首 - 我只是不知道为什么。
最佳答案
您的 Cypher 查询有拼写错误。 Cypher 区分大小写 variable declarations .
Variable names are case sensitive, and can contain underscores and alphanumeric characters (a-z, 0-9), but must always start with a letter. If other characters are needed, you can quote the variable using backquote (`) signs
尝试一下:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///seshatdata/sellable_unit_features.csv" AS line
WITH line, SPLIT(line.ship_dt, '-') AS date
CREATE (sellableunit:SellableUnit {sellable_unit_id: line.sellable_unit_id, sellable_unit_nm: line.sellable_unit_nm, sellable_unit_version_id: line.sellable_unit_version_id})
MERGE (feature:Feature {Feature_id:line.feature_id, feature_nm: line.feature_nm})
CREATE (sellableUnit)-[r:CONTAINS]->(feature)
SET r.start_year = TOINT(date[0]);
您将节点存储到名为 sellableUnit
(小写)的变量中,但在 CREATE
语句中使用名为 SellableUnit
(大写)的变量S)。 功能
也是如此。
关于csv - neo4j 导入带有关系的 CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45486344/