Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-25-2021 07:34 AM
I have a set of nodes to track trip for trucks with GPS location sequence like
(t:Trip)-[:AT_LOCATION]-(g:GPSLocation)-[:NEXT*]->(g2:GPSLocation)
g and g2 gives me list of nodes.
I want to update the relationship between each subsequent nodes with the distance and time between each of the GPSLocation node. The data is present as a point() and datetime() in each of the GPS location nodes.
I am having difficulty to find a way to get the node(0) and node(1) and update the NEXT relationship with property for distance and time between each of the nodes.
I have tried to COLLECT() but do not know how to access the 1st, and 2nd, 2nd and 3rd and so on nodes.
Sorry if this sounds really trivial but it just escapes me.
Solved! Go to Solution.
05-25-2021 11:13 AM
Hello @vignes_k1
You can simplify the problem since you want to update all relationships (I don't know the name of your properties):
MATCH (a:GPSLocation)-[r:NEXT]->(b:GPSLocation)
SET r.distance = distance(a.point, b.point), r.duration = a.date - b.date
If you have a lot to update, you can use: apoc.periodic.iterate() function.
Regards,
Cobra
05-25-2021 11:13 AM
Hello @vignes_k1
You can simplify the problem since you want to update all relationships (I don't know the name of your properties):
MATCH (a:GPSLocation)-[r:NEXT]->(b:GPSLocation)
SET r.distance = distance(a.point, b.point), r.duration = a.date - b.date
If you have a lot to update, you can use: apoc.periodic.iterate() function.
Regards,
Cobra
All the sessions of the conference are now available online