[SERVER-1309] Creating a named index which key has already existed doesn't get any warning Created: 28/Jun/10  Updated: 03/Dec/15  Resolved: 03/Dec/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 1.5.2
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Che-Ching Wu Assignee: David Storch
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

using python driver


Operating System: ALL
Participants:

 Comments   
Comment by David Storch [ 03/Dec/15 ]

The shell now indicates that a new index was not built with the note "all indexes already exist":

> db.x.ensureIndex({x: 1}, {name: "second_index"})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 2,
	"numIndexesAfter" : 2,
	"note" : "all indexes already exist",
	"ok" : 1
}

Comment by Che-Ching Wu [ 28/Jun/10 ]

Please use this example in shell:

> use mydb
switched to db mydb
> db.mycoll.ensureIndex(

{x:1}

,

{name:'first'}

)
> db.mycoll.ensureIndex(

{x:1}

,

{name:'second'}

)
> db.mycoll.getIndexes()
[
{
"name" : "id",
"ns" : "mydb.mycoll",
"key" :

{ "_id" : 1 }

},
{
"_id" : ObjectId("4c2823ee1569936cf28fd53d"),
"ns" : "mydb.mycoll",
"key" :

{ "x" : 1 }

,
"name" : "first"
}
]
>

Generated at Thu Feb 08 02:56:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.