Indexing Reference索引引用

On this page本页内容

Indexing Methods in mongoshmongosh中的索引方法

Name名称Description描述
db.collection.createIndex()Builds an index on a collection.在集合上建立索引。
db.collection.dropIndex()Removes a specified index on a collection.删除集合上的指定索引。
db.collection.dropIndexes()Removes all indexes on a collection.删除集合上的所有索引。
db.collection.getIndexes()Returns an array of documents that describe the existing indexes on a collection.返回描述集合上现有索引的文档数组。
db.collection.reIndex()Rebuilds all existing indexes on a collection.重建集合上的所有现有索引。
db.collection.totalIndexSize()Reports the total size used by the indexes on a collection. 报告集合上索引使用的总大小。Provides a wrapper around the totalIndexSize field of the collStats output.collStats输出的totalIndexSize字段周围提供包装。
cursor.explain()Reports on the query execution plan for a cursor.报告游标的查询执行计划。
cursor.hint()Forces MongoDB to use a specific index for a query.强制MongoDB对查询使用特定索引。
cursor.max()Specifies an exclusive upper index bound for a cursor. 指定游标的独占索引上限。For use with cursor.hint()用于cursor.hint()
cursor.min()Specifies an inclusive lower index bound for a cursor. 指定游标的包含性索引下限。For use with cursor.hint()用于cursor.hint()

Indexing Database Commands索引数据库命令

Name名称Description描述
createIndexesBuilds one or more indexes for a collection.为集合生成一个或多个索引。
dropIndexesRemoves indexes from a collection.从集合中删除索引。
compactDefragments a collection and rebuilds the indexes.对集合进行分片整理并重建索引。
reIndexRebuilds all indexes on a collection.重建集合上的所有索引。
validateInternal command that scans for a collection's data and indexes for correctness.扫描集合数据和索引的正确性的内部命令。
geoSearchRemoved in MongoDB 5.0.在MongoDB 5.0中删除。 Performs a geospatial query that uses MongoDB's haystack index functionality.使用MongoDB的haystack索引功能执行地理空间查询。
checkShardingIndexInternal command that validates index on shard key.验证分片键索引的内部命令。
setIndexCommitQuorumChanges 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描述
$geoWithinSelects geometries within a bounding GeoJSON geometry. 选择边界GeoJSON几何体中的几何体。The 2dsphere and 2d indexes support $geoWithin.2dsphere2d索引支持$geoWithin
$geoIntersectsSelects geometries that intersect with a GeoJSON geometry. 选择与GeoJSON几何体相交的几何体。The 2dsphere index supports $geoIntersects.2dsphere索引支持$geoIntersects
$nearReturns geospatial objects in proximity to a point. 返回接近点的地理空间对象。Requires a geospatial index. 需要地理空间索引。The 2dsphere and 2d indexes support $near.2dsphere2d索引支持$near
$nearSphereReturns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. 返回球体上某个点附近的地理空间对象。需要地理空间索引。 The 2dsphere and 2d indexes support $nearSphere.2dsphere2d索引支持$nearSphere
←  Create Queries that Ensure SelectivitySecurity →