2016-10-28 59 views
0

我是新來ArangoDB和NoSQL一般,我研究ArangoDB因爲我已經跑了兩個簡單的例子正確 https://mikewilliamson.wordpress.com/2014/05/07/arangodbs-geo-spatial-functions/ArangoDB地理空間陣列

define geo index in ArangoDB

現在的空間查詢

,當我嘗試申請我目前的文件,我似乎無法使其工作

這裏是我的JSON文件的示例

{ 
    "branches": [ 
{ 
    "currentGeoLocation": { 
    "latitude": -10, 
    "longitude": 1 
    } 
} 
], 
"name": "example" 
} 

我曾嘗試以下查詢,沒有運氣

LET coll = (FOR item IN positions 
RETURN { 
name:item.name, 
lat:item.branches[0].currentGeoLocation.latitude, 
lng:item.branches[0].currentGeoLocation.longitude 
}) 

FOR geo IN WITHIN(coll, -10, 1, 1) RETURN geo 
----------- 

FOR item in positions 
FOR branch in item.branches 
for geo in within(branch,-10,2,1) 
return geo 

誰能幫助我如何獲得geoLocations收集正確,以獲得地理查詢運行嗎?

此外,我已經用mongosh定義了幾何索引,沒有任何錯誤: db.positions.ensureGeoIndex('latitude','longitude');

回答

0

我認爲問題是你的索引是在你的文檔中的兩個浮點屬性,而不是兩個數組的浮點數。 Arango不會抱怨,因爲它是NoSQL,它假定也許有一天你會創建文件,將有它期望的領域。 AFAIK,您只能在非數組字段上創建地理索引。也許如果你將數組元素分佈到另一個集合中的文檔中,並通過邊連接到它們,你可以做你正在嘗試的搜索。