MongoDB Documentation, Release 3.0.4 See also: 8.2.3 Index Creation The collection has a sparse index on the field score : db.scores.createIndex( { score: 1 } , { sparse: true } ) Because the document for the userid "newbie" does not contain the score field, the sparse index does not contain an entry for that document. Consider the following query to return all documents in the scores collection, sorted by the score field: db.scores.find().sort( { score: -1 } ) Even though the sort is by the indexed field, MongoDB will not select the sparse index to fulfill the query in order to return complete results: { "_id" : ObjectId("523b6e6ffb408eea0eec2649"), "userid" : "nina", "score" : 90 } { "_id" : ObjectId("523b6e61fb408eea0eec2648"), "userid" : "abby", "score" : 82 } { "_id" : ObjectId("523b6e32fb408eea0eec2647"), "userid" : "newbie" } To use the sparse index, explicitly specify the index with hint() : db.scores.find().sort( { score: -1 } ).hint( { score: 1 } ) The use of the index results in the return of only those documents with the score field: { "_id" : ObjectId("523b6e6ffb408eea0eec2649"), "userid" : "nina", "score" : 90 } { "_id" : ObjectId("523b6e61fb408eea0eec2648"), "userid" : "abby", "score" : 82 } explain() and Analyze Query Performance (page 111) Sparse Index with Unique Constraint Consider a collection scores that contains the following documents: You could create an index with a unique constraint (page 504) and sparse filter on the score field using the following operation: { "_id" : ObjectId("523b6e32fb408eea0eec2647"), "userid" : "newbie" } { "_id" : ObjectId("523b6e61fb408eea0eec2648"), "userid" : "abby", "score" : 82 } { "_id" : ObjectId("523b6e6ffb408eea0eec2649"), "userid" : "nina", "score" : 90 } db.scores.insert( { "userid": "AAAAAAA", "score": 43 } ) db.scores.insert( { "userid": "BBBBBBB", "score": 34 } ) db.scores.insert( { "userid": "CCCCCCC" } ) db.scores.insert( { "userid": "DDDDDDD" } ) db.scores.createIndex( { score: 1 } , { sparse: true , unique: true } ) This index would permit the insertion of documents that had unique values for the score field or did not include a score field. Consider the following insert operation (page 92): However, the index would not permit the addition of the following documents since documents already exists with score value of 82 and 90 : db.scores.insert( { "userid": "AAAAAAA", "score": 82 } ) db.scores.insert( { "userid": "BBBBBBB", "score": 90 } ) MongoDB provides several options that only affect the creation of the index. Specify these options in a document as the second argument to the db.collection.createIndex() method. This section describes the uses of these 507 8.2. Index Concepts