Error 16755 - Mongo can't extract geo keys Error 16755 - Mongo can't extract geo keys mongodb mongodb

Error 16755 - Mongo can't extract geo keys


You are correct that the error is because of the invalid geo coordinates you have in that document (see 2dsphere indexes).

Assuming this is the document you have:

> db.test.find(){  "_id": ObjectId("566990eea9c7a38740a305a3"),  "id": 50,  "guid": "NL7a09b334-7524-102d-a4ef-00163e5faa0c",  "version": 0,  "owner": 118,  "published": 1,  "loc": [    -9999,    -9999  ],  "logo": "69db95d0-d58d-40cf-80d3-ac80b8c86af8.png"}

The easiest method is to use the mongo shell to perform an update, by using the ObjectId and do a $set on the loc field. For example, by setting the loc field to a valid coordinate (e.g. [-73.97, 40.77]):

> db.test.update({"_id": ObjectId("566990eea9c7a38740a305a3")}, {$set:{loc:[-73.97, 40.77]}})Updated 1 existing record(s) in 1msWriteResult({  "nMatched": 1,  "nUpserted": 0,  "nModified": 1})

Note that in the example above, I'm using the _id field, which is guaranteed to be unique, so that the update command will only update that exact document. After that, your 2dsphere index creation should succeed:

> db.test.createIndex({loc:'2dsphere'}){  "createdCollectionAutomatically": false,  "numIndexesBefore": 1,  "numIndexesAfter": 2,  "ok": 1}