neo4j - Inserver 距离计算和结合 Neo4j 查询
问题描述
我有两个查询需要在 neo4j 服务器上同时执行。第一个查询需要计算距离。第二个查询需要在 JSON 响应中发送信息+计算的距离请建议我如何在 Neo4j 中结合上述查询?
查询1:
=======
WITH point({ longitude:76.91859, latitude:8.487992, height: 100 }) AS p1, point({ latitude:8.495548 , longitude:76.93015, height: 100 }) AS p2 RETURN distance(p1,p2) AS dist
查询2:
MATCH (qperson:QuarantinedPersons)
WHERE qperson.name = 'Raman'
CREATE (thereturnrecord:theDetails{theid: qperson.id,thename:
qperson.Name,thedetails:qperson.details,thelat:qperson.lat,thelong:qperson.long,thedistance:2000})
RETURN thereturnrecord
预期输出,类似于:
[
{
"thereturnrecord": {
"identity": 3,
"labels": [
"theDetails"
],
"properties": {
"thelong": "76.91859",
"thelat": "8.487992",
"thedetails": "XYZ",
"thedistance": 2000(Obtained from the query),
"theid": "1"
}
}
}
解决方案
[更新]
这是一个组合查询:
WITH
point({ longitude:76.91859, latitude:8.487992, height: 100 }) AS p1,
point({ latitude:8.495548 , longitude:76.93015, height: 100 }) AS p2
MATCH (q:QuarantinedPersons)
WHERE q.name = 'Raman'
CREATE (thereturnrecord:theDetails{
theid: q.id,
thename: q.Name,
thedetails: q.details,
thelat: q.lat,
thelong: q.long,
thedistance: distance(p1, p2)
})
RETURN thereturnrecord
其中,如果 2的参数作为参数point
传递,并且: p1
p2
MATCH (q:QuarantinedPersons)
WHERE q.name = 'Raman'
CREATE (thereturnrecord:theDetails{
theid: q.id,
thename: q.Name,
thedetails: q.details,
thelat: q.lat,
thelong: q.long,
thedistance: distance(point($p1), point($p2))
})
RETURN thereturnrecord
推荐阅读
- c# - EF Core 5 在尝试更新也是唯一索引的一部分的外键时失败
- reactjs - 不变违规:您不应该在 a 之外使用 withRouter()
(带有最小的工作示例) - mysql - 向 MySQL V8 提供 root 密码失败
- reactjs - material-ui 选择下拉菜单看起来像一个芯片
- python - 如何初始化这个使用多重继承的派生类?
- node.js - 出了点问题,查询留在了编译的代码中
- c++ - 在实例化类模板时使用内部类模板时出现编译器错误
- r - 添加一个箭头(位于绘图之外),它指向 x 轴并且是 R 中 ggarrange 绘图的一部分
- angular - Angular AOT 产生 NG8001、NG8002 和 NG8003 错误
- java - 没有代码重复的 Java Entity 和 BusinessObject