Navigation
This version of the documentation is archived and no longer supported.

Index Types

MongoDB provides a number of different index types. You can create indexes on any field or embedded field within a document or embedded document.

In general, you should create indexes that support your common and user-facing queries. Having these indexes will ensure that MongoDB scans the smallest possible number of documents.

In the mongo shell, you can create an index by calling the ensureIndex() method. For more detailed instructions about building indexes, see the Indexing Tutorials page.

Single Field Indexes
A single field index only includes data from a single field of the documents in a collection. MongoDB supports single field indexes on fields at the top level of a document and on fields in sub-documents.
Compound Indexes
A compound index includes more than one field of the documents in a collection.
Multikey Indexes
A multikey index is an index on an array field, adding an index key for each value in the array.
Geospatial Indexes and Queries
Geospatial indexes support location-based searches on data that is stored as either GeoJSON objects or legacy coordinate pairs.
Text Indexes
Text indexes support search of string content in documents.
Hashed Index
Hashed indexes maintain entries with hashes of the values of the indexed field and are primarily used with sharded clusters to support hashed shard keys.