直观的界面可简化任何数据类型(包括数组、地理空间和时间序列数据)的复杂数据工作负载处理,所有这些都使开发者能够用更少的代码交付更多的工作。
- 用您的首选语言工作
- 用于操作、分析和搜索工作负载的单一界面
功能概览
表达式查询
使用一系列强大的运算符(例如 $elemMatch 和 $geoWithin)根据条件组合(包括嵌套数组和对象内的组合条件)查询和更新一个或多个文档。
多种索引类型
无论字段嵌套的深度如何,都可以优化查询多种索引类型。
地理空间和图数据
轻松查询地理空间数据,并使用 $graphLookup 等运算符来遍历已连接的数据集。
跨集合和数据库查询
使用 $lookup 和 $unionWith 加入及融合多个集合,或使用 Atlas Data Federation 跨数据库查询,以便进行深入分析和探索。
就地转换和分析数据
使用聚合管道以简单、模块化的方式构建复杂的转换。
专为文档模型而构建的全文检索
部署高级的全文检索功能,无需管理额外的基础设施。
变更流
构建实时的事件驱动型应用程序,以通过触发服务器端逻辑对数据库变更做出反应。
按需增量物化视图
预先计算并缓存常见查询,以便在处理新数据时动态更新结果集。
简化数据处理
查看文档
让表达式查询变得简单
轻松查询多种数据类型,包括地理空间、图、时间序列以及嵌套数组和对象,同时还能使用首选语言完成所有操作。
Python
Javascript
Java
MongoShell
xxxxxxxxxx
#Querying on arrays
db.inventory.find({
“Size.h”: {$lt: 15}, “size.uom”: “in”, status: “D”
})
#Geospatial queries
db.places.find(
{
location:
{ $near:
{
$geometry: { type: "Point", coordinates: [ -73.9667, 40.78 ] },
$minDistance: 1000,
$maxDistance: 5000
}
}
}
)
可组合的数据库内转换
构建模块化、多阶段聚合管道,从而运行强大的分析。跨集合和数据库查询,且转换数据从而显示见解并做出更明智的决策。
Python
Javascript
Java
MongoShell
xxxxxxxxxx
lonely_ne = db.lonely_neighborhoods
popular_ne = db.popular_neighborhoods
pipeline = [
#filter neighborhoods where the population is known
{"$match": {"population": {"$ne": "unknown"}}},
#perform a union with the collection containing popular neighborhoods with an embedded pipeline for filtering neighborhoods where the population is known, and removing documents where the city is an industrial township
{"$unionWith": {"coll": "popular_neighborhoods",
"pipeline": [
{"$match": {"population": {"$ne": "unknown"}}},
{$redact: {$cond: {
if: { $eq: [ "$type", "Industrial township"]},
then: "$$PRUNE",
else: "$$DESCEND" }}
}
] }},
#finally we are grouping neighborhoods by climate to calculate the total population in popular neighborboods that are not in an industrial township
{"$group": {"_id": "$climate", "totalPopulation": {"$sum": {"$toLong": "$population"}}}}
]
result = lonely_ne.aggregate(pipeline)
全文搜索、时间序列等
使用单一界面创建支持搜索工作负载、时间序列工作负载和事件驱动型应用程序的复杂查询。节省集成多个 API 或复杂 ETL 的时间。
Python
Javascript
Java
MongoShell
xxxxxxxxxx
#running a full-text search query
movies = db.movies
pipeline = [
{"$search": {"near": {"path": "released", "origin": {"$date": "2011-09-01T00:00:00.000+00:00"}, "pivot": 7776000000}}}},
{"$project": {"_id": 0, "title": 1, "released": 1}}
]
result = movies.aggregate(pipeline)
#analyzing time series with window functions
cakeSales = db.cakeSales
pipeline = [
{"$setWindowFields": {
"partitionBy": {"$year": "$orderDate"},
"sortBy": {"orderDate": 1},
"output": {"cumulativeQuantityForYear": {"$sum": "$quantity", "window": {"documents": ["unbounded", "current"]}}}
}
}
]
result = cakeSales.aggregate(pipeline)
for res in result:
print(res)
查询、转换、分析
了解 Query API 必须提供的功能,以及它如何助力其他组织转换其应用程序和工作流。
充分利用 Atlas
利用 MongoDB 开发者数据平台的其他功能,提供更多的数据驱动体验和见解。
使用以下方法构建 MongoDB 数据库:
- CRUD
- 聚合
- 变更流
- 地理空间和图
- 全文搜索
- 多语言驱动程序