简体   繁体   中英

Neo4j Rounding Relationship

everybody

I have two nodes (S1,S2).

S1 is

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 );

The S1 node property vlaues are :

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 is

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 );

The S2 node property values are:

ID     Depth_m
1       100.25
2       101.55  
3       102.75

So, I want to establish a relationship between the values of the two nodes, provided in which values (Depth_m) of S1 and S2 are approximately same (with a small difference ~ 0.5).

Eg, result should be:

   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 

Can ROUND solves this issue? If it can do something, How I can use it?

Thanks)

This query (for handling the S2.csv file) should do what you want:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM