我是使用Neo4j的初学者,我最近创建了两个节点。 节点是:(Service1,Service2)
服务1:
USING PERIODIC COMMIT
LOAD CSV with HEADERS FROM "file:/Serv1.csv" AS line
CREATE (S:Services:Service1 {ID: TOINT (line.ID)})
set S.CCL_mv =ToFloat (line.CCL_mv);
第一个节点的结果是:
ID CCL_mv
1 234.00
2 0
3 0
4 -503.00
5 413.00
6 -510.00
7 0
8 488.00
9 -488.00
10 0
11 0
12 0
13 99.23
14 -99.00
15 0
16 0
18 101.00
19 0
20 0
21 221.0
服务2:
USING PERIODIC COMMIT
LOAD CSV with HEADERS FROM "file:/Serv2.csv" AS line
CREATE (S: Services: Service2 {ID: TOINT (line.ID)})
S.Depth_m =ToFloat (line.Depth_m);
第二个节点的结果是:
ID Depth_m
1 2010.14
2 1998.97
3 1998,36
4 1987,10
5 1976,30
6 1965,24
我想在(Srvice1& Service2)之间保持这种关系 当Service1中的(CCL_mv)不等于0(<> 0)时,它应该匹配Service2的第一行,如:
Service1 Service2
ID CCL_mv ID Depth_m
1 234.00 =========> 1 2010.14
4 -503.00|
5 413.00| =========> 2 1998.97
6 -510.00|
8 488.00|
9 488.00| =========> 3 1998,36
13 099.23|
14 -099.00| =========> 4 1987,10
And so on
答案 0 :(得分:0)
尝试以下代码。当两个数组中都有一对一映射时,这将正常工作。当类型Service1
的节点数大于类型Service2
时,您可能需要检查此查询。我没有测试那种情况。
MATCH (n:Service1) WHERE n.CCL_mv <> 0
WITH collect(n) as source
WITH source, range(0, size(source)) AS index
UNWIND index as i
MATCH (m:Service2) WHERE i+1 = m.ID
WITH source[i] as from, m
CREATE (from)-[r:By_CCL]->(m) RETURN r