Indexing Reference
Indexing Methods in mongosh
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. | |
Removed in MongoDB 5.0. 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 . |