[SERVER-4623] createIndex command does not fail from the shell when the index already exists Created: 05/Jan/12  Updated: 16/Aug/18  Resolved: 16/Aug/18

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.0.2, 2.1.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Sridhar Nanjundeswaran Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

db.foo.createIndex(

{bar:1}

) followed by the same command in the shell does not give an error. Expect this to throw an error when using createIndex as opposed to ensureIndex.



 Comments   
Comment by Asya Kamsky [ 16/Aug/18 ]

This already works as the request describes:

{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 2,
	"numIndexesAfter" : 2,
	"note" : "all indexes already exist",
	"ok" : 1
}

Comment by Swapnil Tailor [ 24/Jan/12 ]

One question related to this issue, Why do we need two different functions for creation of indexes.
Why ensureIndex at all if we can just have createIndex with the same behavior?

Generated at Thu Feb 08 03:06:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.