所以,我是一个彻头彻尾的菜鸟,我一直在为这段代码而苦苦挣扎,我知道这是一件简单的事情,但尽管如此。
我知道变量的范围从 WITH 更改为 WITH 语句,但它是否也随 where 语句而变化。? 我需要返回一个具有相应纬度和经度的节点。 我不能调用"live"变量,因为它不在范围内 - 或者 neo4j 桌面说
这是我的代码
load csv with headers from "file:///latlong1.csv" as home
load csv with headers from "file:///latlong2.csv" as live
WITH point({ latitude:toFloat(home.lath), longitude:toFloat(home.longh)}) AS p1,
point({ latitude:toFloat(live.latl), longitude:toFloat(live.longl)}) AS p2
with toInteger(distance(p1,p2)/1000) AS km
where km > 5
merge (redalert{dist:km, Latitude:live.latl, Longitude:live.longl})
return redalert
如果有人能帮助我使用替代修改的代码,那将是一种祝福!
提前致谢
您需要在每个WITH
中包含live
,以便它在查询中继续存在。试试这个,看看它是否有效。
load csv with headers from "file:///latlong1.csv" as home
load csv with headers from "file:///latlong2.csv" as live
WITH live, point({ latitude:toFloat(home.lath), longitude:toFloat(home.longh)}) AS p1,
point({ latitude:toFloat(live.latl), longitude:toFloat(live.longl)}) AS p2
with live, toInteger(distance(p1,p2)/1000) AS km
where km > 5
merge (redalert{dist:km, Latitude:live.latl, Longitude:live.longl})
return redalert