mirror of https://gitee.com/bigwinds/arangodb
31 lines
1.5 KiB
Plaintext
31 lines
1.5 KiB
Plaintext
avocado> db.complex.drop()
|
|
true
|
|
|
|
avocado> for (i = -90; i <= 90; i += 10)
|
|
.......> for (j = -180; j <= 180; j += 10)
|
|
.......> db.complex.save({ name : "Name_" + i + "_" + j,
|
|
.......> home : [ i, j ],
|
|
.......> work : [ -i, -j ] });
|
|
|
|
avocado> db.complex.near(0, 170).limit(5);
|
|
encountered error while printing: cannot locate suitable geo index
|
|
|
|
avocado> db.complex.ensureGeoIndex("position");
|
|
avocado> db.complex.near(0, 170).limit(5);
|
|
{ "name" : "Name_0_170", "home" : [ 0, 170 ], "work" : [ 0, -170 ], "_id" : "..." }
|
|
{ "name" : "Name_0_180", "home" : [ 0, 180 ], "work" : [ 0, -180 ], "_id" : "..." }
|
|
{ "name" : "Name_10_170", "home" : [ 10, 170 ], "work" : [ -10, -170 ], "_id" : "..." }
|
|
{ "name" : "Name_-10_170", "home" : [ -10, 170 ], "work" : [ 10, -170 ], "_id" : "..." }
|
|
{ "name" : "Name_0_-180", "home" : [ 0, -180 ], "work" : [ 0, 180 ], "_id" : "..." }
|
|
|
|
avocado> db.complex.geo("work").near(0, 170).limit(5);
|
|
encountered error while printing: cannot locate suitable geo index
|
|
|
|
avocado> db.complex.ensureGeoIndex("work");
|
|
avocado> db.complex.geo("work").near(0, 170).limit(5);
|
|
{ "name" : "Name_0_-170", "home" : [ 0, -170 ], "work" : [ 0, 170 ], "_id" : "..." }
|
|
{ "name" : "Name_0_-180", "home" : [ 0, -180 ], "work" : [ 0, 180 ], "_id" : "..." }
|
|
{ "name" : "Name_-10_-170", "home" : [ -10, -170 ], "work" : [ 10, 170 ], "_id" : "..." }
|
|
{ "name" : "Name_10_-170", "home" : [ 10, -170 ], "work" : [ -10, 170 ], "_id" : "..." }
|
|
{ "name" : "Name_0_180", "home" : [ 0, 180 ], "work" : [ 0, -180 ], "_id" : "..." }
|