Indexing Reference
On this page
This version of the documentation is archived and no longer
supported. View the current documentation to learn how to
upgrade your version of MongoDB.
Indexing Methods in the mongo
Shell
Name | Description |
---|---|
Builds an index on a collection. | |
Removes a specified index on a collection. | |
Removes all indexes on a collection. | |
Returns an array of documents that describe the existing indexes on a collection. | |
Rebuilds all existing indexes on a collection. | |
Reports the total size used by the indexes on a collection. Provides a wrapper around the totalIndexSize field of the collStats output. | |
Reports on the query execution plan for a cursor. | |
Forces MongoDB to use a specific index for a query. | |
Specifies an exclusive upper index bound for a cursor. For use with cursor.hint() | |
Specifies an inclusive lower index bound for a cursor. For use with cursor.hint() |
Indexing Database Commands
Name | Description |
---|---|
Builds one or more indexes for a collection. | |
Removes indexes from a collection. | |
Defragments a collection and rebuilds the indexes. | |
Rebuilds all indexes on a collection. | |
Internal command that scans for a collection's data and indexes for correctness. | |
Performs a geospatial query that uses MongoDB's haystack index functionality. | |
Internal command that validates index on shard key. | |
Changes the minimum number of data-bearing members (i.e commit
quorum), including the primary, that must vote to commit an
in-progress index build before the primary marks
those indexes as ready. |
Geospatial Query Selectors
Name | Description |
---|---|
Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support
$geoWithin . | |
Selects geometries that intersect with a GeoJSON geometry.
The 2dsphere index supports
$geoIntersects . | |
Returns geospatial objects in proximity to a point on a sphere.
Requires a geospatial index. The 2dsphere and 2d indexes support
$nearSphere . |
Indexing Query Modifiers
Name | Description |
---|---|
Forces MongoDB to report on query execution plans. See explain() . | |
Forces MongoDB to use a specific index. See hint() | |
Specifies an exclusive upper limit for the index to use in a query. See max() . | |
Specifies an inclusive lower limit for the index to use in a query. See min() . | |
Forces the cursor to only return fields included in the index. |