简体   繁体   中英

ArangoDB geospatial array

I'm new to ArangoDB and NoSQL in general, I'm researching ArangoDB for the spatial queries

I have ran two simple examples correctly https://mikewilliamson.wordpress.com/2014/05/07/arangodbs-geo-spatial-functions/

define geo index in 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

{
  "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?

Also, I have already defined the geo indexes with mongosh without any errors: 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. AFAIK, you can only create a geo index on non-array fields. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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