0

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');

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.