我是neo4j的新手。有人可以帮我加载以下边缘文件格式的脚本吗?
带标题的文件格式(所有字符串) 产品1,PRODUCT_PROPERTY1,产品2,PRODUCT_PROPERTY2
以下是我尝试编写加载脚本
LOAD CSV WITH HEADERS FROM "products.csv" AS row
CREATE (p1:Product1)
SET p1 = row,
p1.event = row.product_property1
CREATE (p2:Product2)
SET p2 = row,
p2.event = row.product_property2
CREATE (p1)-[:depends]-(p2)
答案 0 :(得分:2)
尝试此查询:
angular.element(document).ready(function () {
$http({
method: "GET",
url: window.location.origin + '/api/Groups/GetGroups',
dataType: "json",
}).then(function successCallback(response) {
$scope.groups = response.data;
}, function errorCallback(response) {
alert("trouble..");
});
});
LOAD CSV WITH HEADERS FROM "file:///path/to/products.csv" AS row
MERGE (p1:Product {name: row.PRODUCT1})
SET p1.event = row.PRODUCT_PROPERTY1
MERGE (p2:Product {name: row.PRODUCT2})
SET p2.event = row.PRODUCT_PROPERTY2
CREATE (p1)-[:DEPENDS_ON]->(p2)
和PRODUCT1
行中的值是某种唯一名称或ID,您应该使用MERGE
Cypher command来避免可能的重复。此外,您应在PRODUCT2
上创建uniqueness constraint以强制实施此唯一性:Product(name)