0
我正在尝试将查询放在一起以查找位于图的节点2km内的节点。说我有从纳斯卡线痕有些geoglyphs数据集:在OrientDB中使用子选择的根空间查询
Name,Latitude,Longitude
Hummingbird,-14.692131,-75.148892
Monkey,-14.706940,-75.138532
Condor,-14.697444,-75.126208
Spider,-14.694145,-75.122381
Spiral,-14.688277,-75.122746
Hands,-14.694459,-75.113881
Tree,-14.693898,-75.114520
Astronaut,-14.745222,-75.079755
Dog,-14.706401,-75.130788
Wing,-14.680309,-75.100385
Parrot,-14.689463,-75.107498
我有使用空间索引创建:
CREATE INDEX GeoGlyph.index.Location
ON GeoGlyph(Latitude,Longitude) SPATIAL ENGINE LUCENE
现在,我想找到的节点中的“手2公里“字形,我可以在此查询由纬度/经度坐标手动输入推杆:
SELECT Name, Latitude, Longitude, $distance AS Distance
FROM GeoGlyph
WHERE [Latitude,Longitude,$spatial]
NEAR [-14.694459,-75.113884,{"maxDistance":2}]
ORDER BY Distance
我得到的结果是:
+----+------+----------+----------+--------------------+
|# |Name |Latitude |Longitude |Distance |
+----+------+----------+----------+--------------------+
|0 |Hands |-14.694459|-75.113884|5.230883384236603E-6|
|1 |Tree |-14.693897|-75.11446 |0.08836486627516459 |
|2 |Spider|-14.694363|-75.12358 |1.0442063409276094 |
|3 |Spiral|-14.688309|-75.12276 |1.1754176535538237 |
|4 |Condor|-14.698346|-75.128334|1.6149944044266815 |
+----+------+----------+----------+--------------------+
到目前为止,这么好。
由于输入坐标有点痛苦,我宁愿只使用名称字段“手”在2公里内寻找字形。
这是我目前卡住的地方。我想我应该能够使用LET block得到我想要的东西...但到目前为止,我已经试过不工作:
SELECT *,$distance AS Distance
FROM GeoGlyph
LET $temp = (SELECT * FROM GeoGlyph WHERE Name = "Hands")
WHERE [Latitude,Longitude,$spatial]
NEAR [$temp.Latitude, $temp.Longitude,{"maxDistance":2}]
ORDER BY Distance
有什么建议?
您能否介绍一下关于first()函数的使用。我正在为与你的问题非常相似的事情而努力,而且你的方法似乎可以解决它。 [http://stackoverflow.com/q/43861961/5013735](http://stackoverflow.com/q/43861961/5013735)试试吧! – Jobel
@jobel嗨,我的理解是,LET $ temp =(SELECT ...)的技巧实际上有$ temp存储结果列表。我的示例键知道$ temp只会有1个条目,因为Name字段是唯一的,我可以使用first()将第一个条目从列表中拉出并引用它的元素。 – TxAG98