APPLIES TO:
MongoDB vCore
Azure Cosmos DB for MongoDB vCore 提供熟悉的 MongoDB 优势体验,同时允许访问 Azure Cosmos DB 提供的增强型企业功能。 它通过遵循 MongoDB 线路协议来确保兼容性,从而允许应用已熟悉的现有客户端驱动程序、SDK 和其他工具。
此处列出了支持的运算符以及任何限制或例外。 任何理解这些协议的客户端驱动程序应该都能够连接到 Azure Cosmos DB for MongoDB。 创建 Azure Cosmos DB for MongoDB vCore 群集时,终结点格式为 *.mongocluster.cosmos.azure.cn
。
Azure Cosmos DB for MongoDB 全面支持 MongoDB 查询语言构造。 可以在下方查找当前支持的数据库命令、运算符、阶段和选项的详细列表。
备注
本文仅列出受支持的服务器命令,并排除客户端包装器函数。 客户端包装器函数(如 deleteMany()
和 updateMany()
)在内部利用 delete()
和 update()
服务器命令。 利用受支持的服务器命令的函数与 Azure Cosmos DB for MongoDB 兼容。
Azure Cosmos DB for MongoDB vCore 支持以下数据库命令:
Category | Command | Feature | ||
v5.0 | v6.0 | v7.0 | ||
Administrative Commands | cloneCollectionAsCapped |
| ||
collMod |
|
|
| |
compact |
|
|
| |
convertToCapped |
| |||
create |
|
|
| |
createIndexes |
|
|
| |
currentOp |
|
|
| |
drop |
|
|
| |
dropDatabase |
|
|
| |
dropConnections | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
dropIndexes |
|
|
| |
filemd5 |
|
|
| |
fsync | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
fsyncUnlock | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
getDefaultRWConcern |
|
|
| |
getClusterParameter |
|
| ||
getParameter |
|
|
| |
killCursors |
|
|
| |
killOp |
|
|
| |
listCollections |
|
|
| |
listDatabases |
|
|
| |
listIndexes |
|
|
| |
logRotate | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
reIndex |
|
|
| |
renameCollection |
|
|
| |
rotateCertificates | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
setFeatureCompatibilityVersion | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
setIndexCommitQuorum |
|
|
| |
setParameter |
|
|
| |
setDefaultRWConcern |
|
|
| |
validateDBMetadata |
|
|
| |
shutdown | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
Aggregation Commands |
aggregate |
|
|
|
count |
|
|
| |
distinct |
|
|
| |
mapReduce | MongoDB 5.0 中已弃用 | |||
Authentication Commands | authenticate |
|
|
|
logout | MongoDB 5.0 中已弃用 | |||
Diagnostic Commands | buildInfo |
|
|
|
collStats |
|
|
| |
connPoolStats |
|
|
| |
connectionStatus |
|
|
| |
dataSize |
|
|
| |
dbHash |
|
|
| |
dbStats |
|
|
| |
explain |
|
|
| |
getCmdLineOpts |
|
|
| |
getLog |
|
|
| |
hello |
|
|
| |
hostInfo |
|
|
| |
listCommands |
|
|
| |
lockInfo |
|
|
| |
ping |
|
|
| |
profile | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
serverStatus |
|
|
| |
shardConnPoolStats | MongoDB 5.0 中已弃用。 Alternative: connPoolStats | |||
top |
|
|
| |
validate |
|
|
| |
whatsmyuri |
|
|
| |
Geospatial Commands | geoSearch | MongoDB 5.0 中已弃用 | ||
查询和写入操作命令 | bulkWrite |
|
|
|
delete |
|
|
| |
find |
|
|
| |
findAndModify |
|
|
| |
getLastError | 在 MongoDB 5.1 中已弃用 | |||
getMore |
|
|
| |
insert |
|
|
| |
resetError | MongoDB 5.0 中已弃用 | |||
update |
|
|
| |
查询计划缓存命令 | 作为一种 PaaS 服务,这将由 Azure 管理。 | |||
Replication Commands | Azure 可管理复制,消除了客户手动复制的必要性。 | |||
角色管理命令 | 目前不受支持,但未来将通过 Azure Active Directory 提供。 | |||
Session Commands | abortTransaction |
|
|
|
commitTransaction |
|
|
| |
endSessions |
|
|
| |
killAllSessions |
|
|
| |
killAllSessionsByPattern |
|
|
| |
killSessions |
|
|
| |
refreshSessions |
|
|
| |
startSession |
|
|
| |
Sharding Commands | enableSharding |
|
|
|
isdbgrid |
|
|
| |
reshardCollection |
|
|
| |
shardCollection |
|
|
| |
unsetSharding | MongoDB 5.0 中已弃用 | |||
addShard | 作为平台即服务 (PaaS) 产品/服务,Azure 负责管理分片管理和再平衡。 用户只需为集合指定分片策略,Azure 将处理剩余的工作。 | |||
addShardToZone | ||||
clearJumboFlag | ||||
abortUnshardCollection | ||||
removeShard | ||||
removeShardFromZone | ||||
setShardVersion | ||||
mergeChunks | ||||
abortMoveCollection | ||||
getShardMap | ||||
analyzeShardKey | ||||
medianKey | ||||
checkMetadataConsistency | ||||
shardingState | ||||
cleanupReshardCollection | ||||
flushRouterConfig | ||||
balancerCollectionStatus | ||||
balancerStart | ||||
balancerStatus | ||||
balancerStop | ||||
configureCollectionBalancing | ||||
listShards | ||||
split | ||||
moveChunk | ||||
updateZoneKeyRange | ||||
movePrimary | ||||
moveRange | ||||
abortReshardCollection | ||||
commitReshardCollection | ||||
refineCollectionShardKey | ||||
configureQueryAnalyzer | ||||
transitionFromDedicatedConfigServer | ||||
transitionToDedicatedConfigServer | ||||
unshardCollection | ||||
系统事件审核命令 | logApplicationMessage |
|
|
|
用户管理命令 | createUser |
|
|
|
dropUser |
|
|
| |
usersInfo |
|
|
| |
dropAllUsersFromDatabase | 目前不受支持,但未来将通过 Azure Active Directory 提供。 | |||
grantRolesToUser | ||||
revokeRolesFromUser | ||||
updateUser |
下面是当前 Azure Cosmos DB for MongoDB vCore 上支持的运算符列表:
备注
AvgObjsize 和 size in “collStats” 和 “dbStats” 仅适用于小于 2 KB 的文档大小。
Category | Command | Feature | ||
v5.0 | v6.0 | v7.0 | ||
比较查询运算符 | $eq |
|
|
|
$gt |
|
|
| |
$gte |
|
|
| |
$in |
|
|
| |
$lt |
|
|
| |
$lte |
|
|
| |
$ne |
|
|
| |
$nin |
|
|
| |
逻辑查询运算符 | $and |
|
|
|
$not |
|
|
| |
$nor |
|
|
| |
$or |
|
|
| |
元素查询运算符 | $exists |
|
|
|
$type |
|
|
| |
评估查询运算符 | $expr |
|
|
|
$jsonSchema* |
|
|
| |
$mod |
|
|
| |
$regex |
|
|
| |
$text |
|
|
| |
$where |
|
|
| |
Geospatial Operators | $geoIntersects |
|
|
|
$geoWithin |
|
|
| |
$box |
|
|
| |
$center |
|
|
| |
$centerSphere |
|
|
| |
$geometry |
|
|
| |
$maxDistance |
|
|
| |
$minDistance |
|
|
| |
$polygon |
|
|
| |
$near |
|
|
| |
$nearSphere |
|
|
| |
数组查询运算符 | $all |
|
|
|
$elemMatch |
|
|
| |
$size |
|
|
| |
位查询运算符 | $bitsAllClear |
|
|
|
$bitsAllSet |
|
|
| |
$bitsAnyClear |
|
|
| |
$bitsAnySet |
|
|
| |
Projection Operators | $ |
|
|
|
$elemMatch |
|
|
| |
$meta |
|
|
| |
$slice |
|
|
| |
杂项查询运算符 | $comment |
|
|
|
$rand |
|
|
| |
$natural |
|
|
| |
字段更新运算符 | $currentDate |
|
|
|
$inc |
|
|
| |
$min |
|
|
| |
$max |
|
|
| |
$mul |
|
|
| |
$rename |
|
|
| |
$set |
|
|
| |
$setOnInsert |
|
|
| |
$unset |
|
|
| |
数组更新运算符 | $ |
|
|
|
$[] |
|
|
| |
$[identifier] |
|
|
| |
$addToSet |
|
|
| |
$pop |
|
|
| |
$pull |
|
|
| |
$push |
|
|
| |
$pullAll |
|
|
| |
$each |
|
|
| |
$position |
|
|
| |
$slice |
|
|
| |
$sort |
|
|
| |
位更新运算符 | $bit |
|
|
|
算术表达式运算符 | $abs |
|
|
|
$add |
|
|
| |
$ceil |
|
|
| |
$divide |
|
|
| |
$exp |
|
|
| |
$floor |
|
|
| |
$ln |
|
|
| |
$log |
|
|
| |
$log10 |
|
|
| |
$mod |
|
|
| |
$multiply |
|
|
| |
$pow |
|
|
| |
$round |
|
|
| |
$sqrt |
|
|
| |
$subtract |
|
|
| |
$trunc |
|
|
| |
数组表达式运算符 | $arrayElemAt |
|
|
|
$arrayToObject |
|
|
| |
$concatArrays |
|
|
| |
$filter |
|
|
| |
$firstN |
|
|
| |
$in |
|
|
| |
$indexOfArray |
|
|
| |
$isArray |
|
|
| |
$lastN |
|
|
| |
$map |
|
|
| |
$maxN |
|
| ||
$minN |
|
| ||
$objectToArray |
|
|
| |
$range |
|
|
| |
$reduce |
|
|
| |
$reverseArray |
|
|
| |
$size |
|
|
| |
$slice |
|
|
| |
$sortArray |
|
| ||
$zip |
|
|
| |
Bitwise Operators | $bitAnd |
|
|
|
$bitNot |
|
|
| |
$bitOr |
|
|
| |
$bitXor |
|
|
| |
布尔表达式运算符 | $and |
|
|
|
$not |
|
|
| |
$or |
|
|
| |
比较表达式运算符 | $cmp |
|
|
|
$eq |
|
|
| |
$gt |
|
|
| |
$gte |
|
|
| |
$lt |
|
|
| |
$lte |
|
|
| |
$ne |
|
|
| |
自定义聚合表达式运算符 | 尚不支持。 | |||
数据大小运算符 | $bsonSize |
|
|
|
$binarySize |
|
|
| |
日期表达式运算符 | $dateAdd |
|
|
|
$dateDiff |
|
|
| |
$dateFromParts |
|
|
| |
$dateFromString |
|
|
| |
$dateSubtract |
|
|
| |
$dateToParts |
|
|
| |
$dateToString |
|
|
| |
$dateTrunc |
|
|
| |
$dayOfMonth |
|
|
| |
$dayOfWeek |
|
|
| |
$dayOfYear |
|
|
| |
$hour |
|
|
| |
$isoDayOfWeek |
|
|
| |
$isoWeek |
|
|
| |
$isoWeekYear |
|
|
| |
$millisecond |
|
|
| |
$minute |
|
|
| |
$month |
|
|
| |
$second |
|
|
| |
$toDate |
|
|
| |
$week |
|
|
| |
$year |
|
|
| |
字面量表达式运算符 | $literal |
|
|
|
Miscellaneous Operators | $getField |
|
|
|
$rand |
|
|
| |
$sampleRate |
|
|
| |
对象表达式运算符 | $mergeObjects |
|
|
|
$objectToArray |
|
|
| |
$setField |
|
|
| |
集表达式运算符 | $allElementsTrue |
|
|
|
$anyElementTrue |
|
|
| |
$setDifference |
|
|
| |
$setEquals |
|
|
| |
$setIntersection |
|
|
| |
$setIsSubset |
|
|
| |
$setUnion |
|
|
| |
字符串表达式运算符 | $concat |
|
|
|
$dateFromString |
|
|
| |
$dateToString |
|
|
| |
$indexOfBytes |
|
|
| |
$indexOfCP |
|
|
| |
$ltrim |
|
|
| |
$regexFind |
|
|
| |
$regexFindAll |
|
|
| |
$regexMatch |
|
|
| |
$replaceOne |
|
|
| |
$replaceAll |
|
|
| |
$rtrim |
|
|
| |
$split |
|
|
| |
$strLenBytes |
|
|
| |
$strLenCP |
|
|
| |
$strcasecmp |
|
|
| |
$substr |
|
|
| |
$substrBytes |
|
|
| |
$substrCP |
|
|
| |
$toLower |
|
|
| |
$toString |
|
|
| |
$trim |
|
|
| |
$toUpper |
|
|
| |
文本表达式运算符 | $meta |
|
|
|
时间戳表达式运算符 | $tsIncrement |
|
|
|
$tsSecond |
|
|
| |
三角表达式运算符 | $sin |
|
|
|
$cos |
|
|
| |
$tan |
|
|
| |
$asin |
|
|
| |
$acos |
|
|
| |
$atan |
|
|
| |
$atan2 |
|
|
| |
$asinh |
|
|
| |
$acosh |
|
|
| |
$atanh |
|
|
| |
$sinh |
|
|
| |
$cosh |
|
|
| |
$tanh |
|
|
| |
$degreesToRadians |
|
|
| |
$radiansToDegrees |
|
|
| |
类型表达式运算符 | $convert |
|
|
|
$isNumber |
|
|
| |
$toBool |
|
|
| |
$toDate |
|
|
| |
$toDecimal |
|
|
| |
$toDouble |
|
|
| |
$toInt |
|
|
| |
$toLong |
|
|
| |
$toObjectId |
|
|
| |
$toString |
|
|
| |
$type |
|
|
| |
累加器($group、$bucket、$bucketAuto、$setWindowFields) | $accumulator |
|
|
|
$addToSet |
|
|
| |
$avg |
|
|
| |
$bottom |
|
| ||
$bottomN |
|
| ||
$count |
|
|
| |
$first |
|
|
| |
$firstN |
|
|
| |
$last |
|
|
| |
$lastN |
|
|
| |
$max |
|
|
| |
$maxN |
|
| ||
$median |
|
|
| |
$mergeObjects |
|
|
| |
$min |
|
|
| |
$percentile |
|
|
| |
$push |
|
|
| |
$stdDevPop |
|
|
| |
$stdDevSamp |
|
|
| |
$sum |
|
|
| |
$top |
|
| ||
$topN |
|
| ||
累加器(在其他阶段) | $avg |
|
|
|
$first |
|
|
| |
$last |
|
|
| |
$max |
|
|
| |
$median |
|
|
| |
$min |
|
|
| |
$percentile |
|
|
| |
$stdDevPop |
|
|
| |
$stdDevSamp |
|
|
| |
$sum |
|
|
| |
变量表达式运算符 | $let |
|
|
|
Window Operators | $sum |
|
|
|
$push |
|
|
| |
$addToSet |
|
|
| |
$count |
|
|
| |
$max |
|
|
| |
$min |
|
|
| |
$avg |
|
|
| |
$stdDevPop |
|
|
| |
$bottom |
|
|
| |
$bottomN |
|
|
| |
$covariancePop |
|
|
| |
$covarianceSamp |
|
|
| |
$denseRank |
|
|
| |
$derivative |
|
|
| |
$documentNumber |
|
|
| |
$expMovingAvg |
|
|
| |
$first |
|
|
| |
$integral |
|
|
| |
$last |
|
|
| |
$linearFill |
|
|
| |
$locf |
|
|
| |
$minN |
|
|
| |
$rank |
|
|
| |
$shift |
|
|
| |
$stdDevSamp |
|
|
| |
$top |
|
|
| |
$topN |
|
|
| |
条件表达式运算符 | $cond |
|
|
|
$ifNull |
|
|
| |
$switch |
|
|
| |
聚合管道阶段 | $addFields |
|
|
|
$bucket |
|
|
| |
$bucketAuto |
|
|
| |
$changeStream |
|
|
| |
$changeStreamSplitLargeEvent |
|
|
| |
$collStats |
|
|
| |
$count |
|
|
| |
$densify |
|
| ||
$documents |
|
| ||
$facet |
|
|
| |
$fill |
|
| ||
$geoNear |
|
|
| |
$graphLookup |
|
|
| |
$group |
|
|
| |
$indexStats |
|
|
| |
$limit |
|
|
| |
$listSampledQueries |
|
|
| |
$listSearchIndexes |
|
|
| |
$listSessions |
|
|
| |
$lookup |
|
|
| |
$match |
|
|
| |
$merge |
|
|
| |
$out |
|
|
| |
$planCacheStats |
|
|
| |
$project |
|
|
| |
$redact |
|
|
| |
$replaceRoot |
|
|
| |
$replaceWith |
|
|
| |
$sample |
|
|
| |
$search |
|
|
| |
$searchMeta |
|
|
| |
$set |
|
|
| |
$setWindowFields |
|
|
| |
$skip |
|
|
| |
$sort |
|
|
| |
$sortByCount |
|
|
| |
$unionWith |
|
|
| |
$unset |
|
|
| |
$unwind |
|
|
| |
$shardedDataDistribution |
|
|
| |
$currentOp |
|
|
| |
$listLocalSessions |
|
|
| |
聚合表达式中的变量 |
NOW |
|
|
|
ROOT |
|
|
| |
REMOVE |
|
|
| |
CURRENT |
|
|
| |
CLUSTER_TIME |
|
|
| |
DESCEND |
|
|
| |
PRUNE |
|
|
| |
KEEP |
|
|
| |
SEARCH_META |
|
|
| |
USER_ROLES |
|
|
|
备注
*架构验证支持:在聚合中插入、更新、查找AndModify 和$merge/$out阶段。 如果需要,请使用 bypassDocumentValidation 跳过验证。
Azure Cosmos DB for MongoDB vCore 支持以下索引和索引属性:
备注
Creating a unique index obtains an exclusive lock on the collection for the entire duration of the build process. 在操作完成前,集合都无法执行读取和写入操作。
Command | Supported |
单字段索引 |
|
Compound Index |
|
Multikey Index |
|
Text Index |
|
Wildcard Index |
|
Geospatial Index |
|
Hashed Index |
|
Command | Supported |
TTL |
|
Unique |
|
Partial |
|
Case Insensitive |
|
Sparse |
|
Background |
|