MongoError: can't find any special indices: 2d (needs index), 2dsphere (needs index) MongoError: can't find any special indices: 2d (needs index), 2dsphere (needs index) mongoose mongoose

MongoError: can't find any special indices: 2d (needs index), 2dsphere (needs index)


Did you try to create the index with this sentence?

db.event.ensureIndex({ "location" : "2d" } )

It's a little confusing your example. I don't get if 'location' are your coordinates or 'geo', because you create the schema with the former and you query with the latter.

In both cases, a good idea is to execute

db.event.findOne().pretty()

So you can check the format of your collection.

Also with this command you can check your current indexes.

db.event.getIndexes()

All of this works if you are working on 'event' collection.