我使用此代码使用纬度和经度获取两点之间的距离,我想使用此返回值作为两个节点(酒店和我)之间的关系属性 代码:///////
MATCH (u:me)-[d:distance]->(n:Hotels)
WITH
point({longitude: u.longitude, latitude: u.latitude}) AS trainPoint,
point({longitude: n.longitude, latitude: n.latitude}) AS officePoint
RETURN round(point.distance(trainPoint, officePoint)) AS travelDistance
我想将返回值添加到关系距离
您可以使用 SET 将属性添加到关系(或节点)。看这里:https://neo4j.com/docs/cypher-manual/current/clauses/set/
举个例子:
MATCH (u:me)-[d:distance]->(n:Hotels)
WITH d,
point({longitude: u.longitude, latitude: u.latitude}) AS trainPoint,
point({longitude: n.longitude, latitude: n.latitude}) AS officePoint
WITH d, round(point.distance(trainPoint, officePoint)) AS travelDistance
SET d.travelDistance = travelDistance
RETURN d