2017-01-02 102 views
0

everyoneNeo4j舍入關係

我有兩個節點(S1,S2)。

S1是

USING PERIODIC COMMIT 
LOAD CSV with HEADERS FROM "file:/S1.csv" AS line 
CREATE (a:S1 {ID: TOINT (line.ID)}) 
set a.Depth_m   =TOINT (line.depth); 

的S1節點屬性vlaues是:

ID  Depth_m 
1  100.06 
2  100.20 
3  100.37 
4  101.29 
5  101.50 
6  101.88 
7  102.42 
8  102.70 
9  102.92 

S2是

USING PERIODIC COMMIT 
LOAD CSV with HEADERS FROM "file:/S2.csv" AS line 
CREATE (b:S2 {ID: TOINT (line.ID)}) 
set b.Depth_m   =TOINT (line.depth); 

的S2節點屬性值是:

ID  Depth_m 
1  100.25 
2  101.55 
3  102.75 

所以,我想建立兩個節點的值之間的關係,其中S1和S2的值(Depth_m)大致相同(差值小於0.5)。

例如,結果應該是:

S1          S2 

ID  Depth_m       ID  Depth_m 
1  100.20  =======>>   1   100.25 
2  101.50  =======>>   2   101.55 
3  102.70  =======>>   3   102.75 

璨圓來解決這個問題?如果可以做一些事情,我如何使用它?

感謝)

回答

0

這個查詢(用於處理S2.csv文件)應該做你想要什麼:

USING PERIODIC COMMIT 
LOAD CSV with HEADERS FROM "file:/S2.csv" AS line 
CREATE (b:S2 {ID: TOINT(line.ID), Depth: TOINT(line.depth)}) 
WITH b 
MATCH (a:S1) WHERE ABS(a.Depth-b.Depth) <= 0.5 
CREATE (a)-[:SIMILAR]->(b);