1
0
Fork 0
arangodb/Documentation/Examples/geoIndexCreateForArrayAttri...

54 lines
1.2 KiB
Plaintext

arangosh> db.geo2.ensureGeoIndex("location.latitude", "location.longitude");
{
"id" : "geo2/2034234251",
"type" : "geo2",
"fields" : [
"location.latitude",
"location.longitude"
],
"constraint" : false,
"unique" : false,
"ignoreNull" : true,
"sparse" : true,
"isNewlyCreated" : true,
"code" : 201
}
arangosh> 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 } });
........> }
........> }
arangosh> db.geo2.near(0, 0).limit(3).toArray();
[
{
"_id" : "geo2/2103636875",
"_key" : "2103636875",
"_rev" : "2103636875",
"location" : {
"latitude" : 0,
"longitude" : 0
},
"name" : "Name/0/0"
},
{
"_id" : "geo2/2103833483",
"_key" : "2103833483",
"_rev" : "2103833483",
"location" : {
"latitude" : 0,
"longitude" : 10
},
"name" : "Name/0/10"
},
{
"_id" : "geo2/2096362379",
"_key" : "2096362379",
"_rev" : "2096362379",
"location" : {
"latitude" : -10,
"longitude" : 0
},
"name" : "Name/-10/0"
}
]