简体   繁体   中英

How to use ensureIndex in MongoDB Java Driver?

I am working with Mongo 2.6.0. How do I use the ensureIndex functionality on a collection? Currently it shows me as deprecated.

Any help would be appreciated.

I assume since you say you're using 2.6 of the server, you're using 2.12 of the Java driver? If you look at the documentation , where the ensureIndex methods are deprecated it tells you which method you should use instead - you should be using createIndex .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM