-
Notifications
You must be signed in to change notification settings - Fork 0
Indexes
Nikolas Bompetsis edited this page May 30, 2020
·
3 revisions
> mongodb master ✗ mongo -u admin -p admin --authenticationDatabase admin
> use project
In our collection named stackoverflow that holds documents, we want to create an index based on one field
> db.stackoverflow.createIndex( { "Country": 1 } )
MongoDB supports compound indexes, where a single index structure holds references to multiple fields and can support queries that match on multiple fields.
> db.stackoverflow.createIndex( { "Country": 1, "Age": 1 } )