Description描述 | Designed with specific goals of improving performance and usability for aggregation tasks.旨在提高聚合任务的性能和可用性。
Uses a "pipeline" approach where objects are transformed as they pass through a series of pipeline stages such as $group, $match, and $sort.使用“管道”方法,对象在通过一系列管道阶段(如$group、$match和$sort)时进行转换。
For more information on pipeline stages, see Aggregation Stages.有关管道阶段的更多信息,请参阅聚合阶段。
| Implements the Map-Reduce aggregation for processing large data sets.实现Map-Reduce聚合以处理大型数据集。 |
Key Features主要特点 | Pipeline operators can be repeated as needed.管道运算符可以根据需要重复操作。
Pipeline operators need not produce one output document for every input document.管道运算符不需要为每个输入文档生成一个输出文档。
Can also generate new documents or filter out documents.还可以生成新文档或筛选掉文档。
Using the $merge stage, you can create on-demand materialized views, where the content of the output collection can be updated incrementally the pipeline is run. $merge can incorporate results (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline) into an existing collection.使用$merge阶段,您可以创建按需的物化视图,其中输出集合的内容可以在管道运行时增量更新。$merge可以将结果(插入新文档、合并文档、替换文档、保留现有文档、操作失败、使用自定义更新管道处理文档)合并到现有集合中。
| In addition to grouping operations, can perform complex aggregation tasks as well as perform incremental aggregation on continuously growing datasets.除了分组操作外,还可以执行复杂的聚合任务,以及对不断增长的数据集执行增量聚合。
See Map-Reduce Examples and Perform Incremental Map-Reduce.请参阅映射缩减示例和执行增量映射缩减。
|
Flexibility灵活性 | You can define custom accumulators with $accumulator and custom expressions with $function.您可以使用$accumulator定义自定义累加器,使用$function定义自定义表达式。
You can also use the $project pipeline stage to add computed fields and reshape existing document fields.您还可以使用$project管道阶段添加计算字段并重塑现有文档字段。
See $project for more information as well as Aggregation Stages for more information on all the available pipeline stages.有关更多信息,请参阅$project,有关所有可用管道阶段的更多信息,也请参阅聚合阶段。
| Custom map, reduce and finalize JavaScript functions offer flexibility to aggregation logic.自定义map、reduce和finalizeJavaScript函数为聚合逻辑提供了灵活性。
See mapReduce for details and restrictions on the functions.有关函数的详细信息和限制,请参阅mapReduce。
|
Output Results输出结果 | Returns results as a cursor. If the pipeline includes the $out stage or $merge stage, the cursor is empty.以游标形式返回结果。如果管道包含$out阶段或$merge阶段,则游标为空。
With $out, you can replace an existing output collection completely or output to a new collection. See $out for details.使用$out,您可以完全替换现有的输出集合或输出到新的集合。详见$out。
With $merge, you can output to a new or existing collection. For existing collections, you can specify how to incorporate the results into the output collection (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline). 使用$merge,您可以输出到新的或现有的集合。对于现有集合,您可以指定如何将结果合并到输出集合中(插入新文档、合并文档、替换文档、保留现有文档、失败操作、使用自定义更新管道处理文档)。See $merge for details.有关详细信息,请参阅$merge。
| Returns results in various options (inline, new collection, merge, replace, reduce). See mapReduce for details on the output options.以各种选项(内联、新集合、合并、替换、减少)返回结果。有关输出选项的详细信息,请参阅mapReduce。 |
Sharding分片 | Supports non-sharded and sharded input collections.支持非分片和分片输入集合。
$merge can output to a non-sharded or sharded collection.$merge可以输出到非分片集合或分片集合。
| Supports non-sharded and sharded input collections.支持非分片和分片输入集合。 |
More Information详细信息 |
|
|