These documents describe and provide examples of the types, configuration options, and behavior of indexes in MongoDB. For an over view of indexing, see Index Introduction. For operational instructions, see Indexing Tutorials. The Indexing Reference documents the commands and operations specific to index construction, maintenance, and querying in MongoDB, including index types and creation options.
MongoDB provides different types of indexes for different purposes and different types of content.
- 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.
- A compound index includes more than one field of the documents in a collection.
- Multikey Indexes
- A multikey index references an array and records a match if a query includes any 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 supports search of string content in documents.
- Hashed Index
- Hashed indexes maintain entries with hashes of the values of the indexed field.
- Index Properties
The properties you can specify when building indexes.
- TTL Indexes
- The TTL index is used for TTL collections, which expire data after a period of time.
- Unique Indexes
- A unique index causes MongoDB to reject all documents that contain a duplicate value for the indexed field.
- A sparse index does not index documents that do not have the indexed field.
- Index Creation
- The options available when creating indexes.