Indexes support the efficient execution of queries in
MongoDB.
Without indexes, MongoDB must perform a collection scan,
i.e. scan every document in a collection, to select those
documents that match the query statement.
It is one of way to create unique constraints similar to SQL
Unique Constraints.
The index stores the value of a specific field or set of
fields, ordered by the value of the field. The ordering of the
index entries supports efficient equality matches and
range-based query operations.
Indexes in MongoDB are similar to indexes in other database
systems.
NOTE:-
MongoDB creates a unique index on the _id field during the
creation of a collection.
The _id index prevents clients from inserting two documents
with the same value for the _id field.