Why aggregate
aggregate.near({
near: coord,
distanceField: "distance",
maxDistance: max
});
can return
{
"name": "MongoError",
"errmsg": "exception: geoNear command failed: { ok: 0.0, errmsg: \"more than one 2d index, not sure which to run geoNear on\" }",
"code": 16604,
"ok": 0
}
having in the scheme the only 2d index:
location: { type: [ Number ], index: '2d', sparse: true },
more or less when i remove EVERYTHING from the scheme the error doenst change why? o why...
When you remove an index (or even an entire field) in your Mongoose model, it is not automatically removed from MongoDB.
Run db.<your collection name>.getIndexes()
to view all indexes. Make a note of the name
of the index you want to remove.
Run db.<your collection name>.dropIndex(<name of the index>)
to remove an index.
By default, Mongoose tells MongoDB to (re-)create indexes ("ensureIndex()
") when you start your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With