OPTIONS

Index Creation TutorialsΒΆ

Instructions for creating and configuring indexes in MongoDB and building indexes on replica sets and sharded clusters.

Create an Index
Build an index for any field on a collection.
Create a Compound Index
Build an index of multiple fields on a collection.
Create a Unique Index
Build an index that enforces unique values for the indexed field or fields.
Create a Partial Index
Build an index that only indexes documents that meet specified filter criteria. This can reduce index size and improve performance.
Create a Sparse Index
Build an index that omits references to documents that do not include the indexed field. This saves space when indexing fields that are present in only some documents.
Create a Hashed Index
Compute a hash of the value of a field in a collection and index the hashed value. These indexes permit equality queries and may be suitable shard keys for some collections.
Build Indexes on Replica Sets
To build indexes on a replica set, you build the indexes separately on the primary and the secondaries, as described here.
Build Indexes in the Background
Background index construction allows read and write operations to continue while building the index, but take longer to complete and result in a larger index.
Build Old Style Indexes
A {v : 0} index is necessary if you need to roll back from MongoDB version 2.0 (or later) to MongoDB version 1.8.

Was this page helpful?

Yes No

Thank you for your feedback!

We're sorry! You can Report a Problem to help us improve this page.