o query
db.alunos.aggregate([
{
$geoNear : {
near : {
coordinates: [-23.5640265, -46.6527128],
type : "Point"
},
distanceField : "distancia.calculada",
spherical : true
}
}
])
db.alunos.createIndex({
localizacao : "2dsphere"
})
não funcionou de esse erro abaixo:
assert: command failed: {
"ok" : 0,
"errmsg" : "geoNear command failed: { ok: 0.0, errmsg: \"more than one 2dsphere index, not sure which to run geoNear on\" }",
"code" : 16604,
"codeName" : "Location16604"
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:403:5
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1212:12
@(shell):1:1
2018-03-17T22:34:27.158-0300 E QUERY [thread1] Error: command failed: {
"ok" : 0,
"errmsg" : "geoNear command failed: { ok: 0.0, errmsg: \"more than one 2dsphere index, not sure which to run geoNear on\" }",
"code" : 16604,
"codeName" : "Location16604"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:403:5
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1212:12
@(shell):1:1
>