On this page
This page describes the types of indexes you can create in MongoDB. Different index types support different types of data and queries.
Single field indexes collect and sort data from a single field in each document in a collection.
This image shows an index on a single field,
To learn more, see Single Field Indexes.
Compound indexes collect and sort data from two or more fields in each document in a collection. Data is grouped by the first field in the index and then by each subsequent field.
For example, the following image shows a compound index where documents
are first grouped by
userid in ascending order (alphabetically).
scores for each
userid are sorted in descending order:
To learn more, see Compound Indexes.
Multikey indexes collect and sort data stored in arrays.
You do not need to explicitly specify the multikey type. When you create an index on a field that contains an array value, MongoDB automatically sets the index to be a multikey index.
This image shows a multikey index on the
To learn more, see Multikey Indexes.
Geospatial indexes improve performance for queries on geospatial coordinate data. To learn more, see Geospatial Indexes.
MongoDB provides two types of geospatial indexes:
Text indexes support text search queries on fields containing string content.
To learn more, see Text Indexes.
Hashed indexes support hashed sharding. Hashed indexes index the hash of the value of a field.
To learn more, see Hashed Indexes.
New in version 5.3.
Clustered indexes specify the order in which clustered collections store data. Collections created with a clustered index are called clustered collections.
To learn how to create a collection with a clustered index, see Clustered Collection Examples.