I’m working with a collection that someone else created, and I need to find out whether an index is unique. Is there anyway to do this from the mongo shell?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can search for indexes with:
db.system.indexes.find();To search for a unique index:
db.system.indexes.find({"unique": true});With that, you can also add more search parameters to find specific indexes by namespace, key, etc.
Edit: Relevant documentation: http://www.mongodb.org/display/DOCS/Index-Related+Commands