简体   繁体   English

ArangoDB地理空间阵列

[英]ArangoDB geospatial array

I'm new to ArangoDB and NoSQL in general, I'm researching ArangoDB for the spatial queries 我是ArangoDB和NoSQL的新手,我正在研究ArangoDB的空间查询

I have ran two simple examples correctly https://mikewilliamson.wordpress.com/2014/05/07/arangodbs-geo-spatial-functions/ 我已经正确运行了两个简单的示例https://mikewilliamson.wordpress.com/2014/05/07/arangodbs-geo-spatial-functions/

define geo index in ArangoDB 在ArangoDB中定义地理索引

Now, when I try to apply to my current documents, I just can't seem to make it work 现在,当我尝试将其应用于当前文档时,我似乎无法使其正常工作

Here is an example of my JSON Doc 这是我的JSON文档的示例

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

I have tried the following queries with no luck 我没有运气尝试过以下查询

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

Can anyone help me on how to get the collection of geoLocations correctly in order to get the geo query running please? 谁能帮助我如何正确获取geoLocations的集合,以便运行geo查询?

Also, I have already defined the geo indexes with mongosh without any errors: db.positions.ensureGeoIndex('latitude','longitude'); 另外,我已经用mongosh定义了地理索引,没有任何错误:db.positions.ensureGeoIndex('latitude','longitude');

I think the problem is that your index is on two floating point properties in your document and not on two two arrays of floating point numbers. 我认为问题在于您的索引位于文档中的两个浮点属性上,而不是在两个两个浮点数数组上。 Arango doesn't complain because it's NoSQL, it assumes that maybe someday you'll create documents that will have the fields it expects. Arango不会抱怨,因为它是NoSQL,它假设也许有一天您将创建具有期望字段的文档。 AFAIK, you can only create a geo index on non-array fields. AFAIK,您只能在非数组字段上创建地理索引。 Perhaps if you distributed the array elements into documents in another collection and linked to them via edges, you can do the searches that you are trying to do. 也许如果您将数组元素分配到另一个集合中的文档中并通过边链接到它们,则可以执行您要执行的搜索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM