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?
            Asked
            
        
        
            Active
            
        
            Viewed 5,578 times
        
    2 Answers
10
            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
 
    
    
        Andz
        
- 2,228
- 19
- 13
7
            
            
        db.<my_collection>.getIndexes()
If some of those indexes are unique, you will see a key named "unique" with the value true.
 
    
    
        Manur
        
- 8,436
- 2
- 27
- 29
