1
0
Fork 0
arangodb/Documentation/Examples/ensure-geo-index-array

31 lines
946 B
Plaintext

arango> db.geo2.ensureGeoIndex("location.latitude", "location.longitude");
{ "id" : "geo2/1070652", "type" : "geo2", "fields" : ["location.latitude", "location.longitude"], "isNewlyCreated" : true }
arango> for (i = -90; i <= 90; i += 10) {
.......> for (j = -180; j <= 180; j += 10) {
.......> db.geo2.save({ name : "Name/" + i + "/" + j,
.......> location: { latitude : i,
.......> longitude : j } });
.......> }
.......> }
arango> db.geo2.near(0,0).limit(3).toArray();
[{
"_id" : "geo2/72964588",
"_rev" : "72964588",
"location" : { "latitude" : 0, "longitude" : 0},
"name" : "Name/0/0"
},
{
"_id" : "geo2/73030124",
"_rev" : "73030124",
"location" : { "latitude" : 0, "longitude" : 10},
"name" : "Name/0/10"
},
{
"_id" : "geo2/70539756",
"_rev" : "70539756",
"location" : { "latitude" : -10, "longitude" : 0},
"name" : "Name/-10/0"
}]