Description
Currently we do not allow users to insert non-geo data (for example, a string) into a field that has a geo index on it. Here is an example:
> db.test.ensureIndex({a: '2dsphere'})
|
{
|
"createdCollectionAutomatically" : false,
|
"numIndexesBefore" : 1,
|
"numIndexesAfter" : 2,
|
"ok" : 1
|
}
|
> db.test.remove({})
|
WriteResult({ "nRemoved" : 0 })
|
> db.test.insert({_id: 0, a: "this is not a test"})
|
WriteResult({
|
"nInserted" : 0,
|
"writeError" : {
|
"code" : 16755,
|
"errmsg" : "insertDocument :: caused by :: 16755 Can't extract geo keys: { _id: 0.0, a: \"this is not a test\" } geo element must be an array or object: a: \"this is not a test\""
|
}
|
})
|
I could not find this limitation documented anywhere. We should make this clear to the users as it is a fairly major limitations of geo indexes.