[JAVA-1197] DBCollection.createIndex/ensureIndex deprecation notice is flipped from MongoDB Manual documentation Created: 01/May/14  Updated: 08/Oct/15  Resolved: 08/Oct/15

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.12.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Hendy Irawan Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

MongoDB Manual recommends ensureIndex :

http://docs.mongodb.org/manual//tutorial/create-an-index/
http://docs.mongodb.org/manual//reference/method/db.collection.ensureIndex/

and deprecates createIndex since very long ago:

http://docs.mongodb.org/manual//reference/method/db.collection.createIndex/

db.collection.createIndex(keys, options)
Deprecated since version 1.8.

Creates indexes on collections.

Java API is the other way around, recommends createIndex:

http://api.mongodb.org/java/current/com/mongodb/DBCollection.html#createIndex(com.mongodb.DBObject) :

createIndex
public void createIndex(DBObject keys)
Calls createIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default index options

and deprecates ensureIndex :

http://api.mongodb.org/java/current/com/mongodb/DBCollection.html#ensureIndex(com.mongodb.DBObject)

ensureIndex
@Deprecated
public void ensureIndex(DBObject keys)
Deprecated. use createIndex(DBObject) instead
Calls ensureIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default options



 Comments   
Comment by Jeffrey Yemin [ 08/Oct/15 ]

Now that the server has implemented a createIndexes command, the driver is going to prefer that name over ensureIndex. I hope this clarifies the situation.

So closing this as Works as Designed.

Generated at Thu Feb 08 08:54:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.