Details
Description
On a collection, I have an existing 2dsphere index (created while still using MongoDB 2.4.x):
{
|
"v" : 1,
|
"key" : {
|
"l" : "2dsphere"
|
},
|
"ns" : "demo.foursquare",
|
"name" : "l_2dsphere"
|
},
|
I have some code that adds stuff from foursquare, and this script runs PHP's ensureIndex() to create the 2dsphere index in case it doesn't exist. On the shell, the equivalant is:
db.foursquare.ensureIndex( { l: '2dsphere' } );
|
However, that generates:
{
|
"ok" : 0,
|
"errmsg" : "Index with name: l_2dsphere already exists with different options",
|
"code" : 67
|
}
|
But I am not setting any new options.
However, when I create a 2dsphere index on a different field (loc instead of l):
db.foursquare.createIndex( { loc: '2dsphere' } );
|
Then it creates this index:
{
|
"v" : 1,
|
"key" : {
|
"loc" : "2dsphere"
|
},
|
"name" : "loc_2dsphere",
|
"ns" : "demo.foursquare",
|
"2dsphereIndexVersion" : 2
|
}
|
(Note the extra "2dsphereIndexVersion" : 2).
When I then run the createIndex again, I get (correctly):
{ "numIndexesBefore" : 4, "note" : "all indexes already exist", "ok" : 1 }
|
It looks like it breaks over the extra 2dsphereIndexVersion "option", but as user I have no influence over that not being set.