List indexes on a collection:
db.posts.getIndexes()
Single-field index
Create an ascending index on score:
db.records.createIndex({ score: 1 })
The value in the index specification is the index direction:
1ascending,-1descending.
That index supports queries that filter on score, for example:
db.records.find({ score: 2 })
db.records.find({ score: { $gt: 10 } })
Compound index
db.products.createIndex({ item: 1, stock: 1 })
Andrew Dorokhov