Skip to content

Commit bd34ab6

Browse files
committed
DOCSP-50497 fixing git rebases and uploading changes to agg pages
1 parent c2de22c commit bd34ab6

File tree

3 files changed

+394
-113
lines changed

3 files changed

+394
-113
lines changed

snooty.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ toc_landing_pages = [
1111
"/connect",
1212
"/security",
1313
"/security/authentication",
14-
"/aggregation-tutorials",
14+
"/aggregation",
1515
"/data-formats",
1616
"/connect/connection-options",
1717
"/crud",

source/aggregation.txt

Lines changed: 72 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,29 @@ Aggregation
1414

1515
.. contents:: On this page
1616
:local:
17+
1718
:backlinks: none
1819
:depth: 2
1920
:class: singlecol
2021

22+
.. toctree::
23+
24+
Pipeline Stages </aggregation/pipeline-stages>
25+
2126
.. _nodejs-aggregation-overview:
2227

2328
Overview
2429
--------
2530

26-
In this guide, you can learn how to use **aggregation operations** in
27-
the MongoDB Node.js driver.
31+
In this guide, you can learn how to use the MongoDB Node.js Driver to perform
32+
**aggregation operations**.
2833

29-
Aggregation operations are expressions you can use to produce reduced
30-
and summarized results in MongoDB. MongoDB's aggregation framework
31-
allows you to create a pipeline that consists of one or more stages,
32-
each of which performs a specific operation on your data.
34+
Aggregation operations process data in your MongoDB collections and return
35+
computed results. The MongoDB Aggregation framework is modeled on the
36+
concept of data processing pipelines. Documents enter a pipeline comprised of one or
37+
more stages, and this pipeline transforms the documents into an aggregated result.
38+
39+
To learn more about the aggregation stages supported by the Node.js Driver, see :ref:`Aggregation Stages <node-aggregation-pipeline-stages>`.
3340

3441
.. _node-aggregation-tutorials:
3542

@@ -42,114 +49,67 @@ each of which performs a specific operation on your data.
4249
Analogy
4350
~~~~~~~
4451

45-
You can think of the aggregation pipeline as similar to an automobile factory.
46-
Automobile manufacturing requires the use of assembly stations organized
47-
into assembly lines. Each station has specialized tools, such as
48-
drills and welders. The factory transforms and
49-
assembles the initial parts and materials into finished products.
50-
51-
The **aggregation pipeline** is the assembly line, **aggregation
52-
stages** are the assembly stations, and **expression operators** are the
53-
specialized tools.
54-
55-
Comparing Aggregation and Query Operations
56-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57-
58-
Using query operations, such as the ``find()`` method, you can perform the following actions:
59-
60-
- Select *which documents* to return
61-
- Select *which fields* to return
62-
- Sort the results
63-
64-
Using aggregation operations, you can perform the following actions:
65-
66-
- Perform all query operations
67-
- Rename fields
68-
- Calculate fields
69-
- Summarize data
70-
- Group values
71-
72-
Aggregation operations have some :manual:`limitations </core/aggregation-pipeline-limits/>`:
73-
74-
- Returned documents must not violate the :manual:`BSON-document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>`
52+
The aggregation pipeline is similar to an automobile factory assembly line. An
53+
assembly line has stations with specialized tools that are used to perform
54+
specific tasks. For example, when building a car, the assembly line begins with
55+
a frame. As the car frame moves though the assembly line, each station assembles
56+
a separate part. The result is a transformed final product, the finished car.
57+
58+
The *aggregation pipeline* is the assembly line, the *aggregation stages* are
59+
the assembly stations, the *expression operators* are the specialized tools, and
60+
the *aggregated result* is the finished product.
61+
62+
Compare Aggregation and Find Operations
63+
---------------------------------------
64+
65+
The following table lists the different tasks you can perform with find
66+
operations compared to what you can achieve with aggregation
67+
operations. The aggregation framework provides expanded functionality
68+
that allows you to transform and manipulate your data.
69+
70+
.. list-table::
71+
:header-rows: 1
72+
:widths: 50 50
73+
74+
* - Find Operations
75+
- Aggregation Operations
76+
77+
* - | Select *certain* documents to return
78+
| Select *which* fields to return
79+
| Sort the results
80+
| Limit the results
81+
| Count the results
82+
- | Select *certain* documents to return
83+
| Select *which* fields to return
84+
| Sort the results
85+
| Limit the results
86+
| Count the results
87+
| Group the results
88+
| Rename fields
89+
| Compute new fields
90+
| Summarize data
91+
| Connect and merge data sets
92+
93+
Server Limitations
94+
------------------
95+
96+
Consider the following :manual:`limitations </core/aggregation-pipeline-limits/>` when performing aggregation operations:
97+
98+
- Returned documents must not violate the :manual:`BSON document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>`
7599
of 16 megabytes.
76100

77-
- Pipeline stages have a memory limit of 100 megabytes by default. You can exceed this
78-
limit by setting the ``allowDiskUse`` property of ``AggregateOptions`` to ``true``. See
79-
the `AggregateOptions API documentation <{+api+}/interfaces/AggregateOptions.html>`__
80-
for more details.
81-
82-
.. important:: $graphLookup exception
83-
84-
The :manual:`$graphLookup
85-
</reference/operator/aggregation/graphLookup/>` stage has a strict
86-
memory limit of 100 megabytes and will ignore ``allowDiskUse``.
87-
88-
References
89-
~~~~~~~~~~
90-
91-
To view a full list of expression operators, see :manual:`Aggregation
92-
Operators </reference/operator/aggregation/>` in the Server manual.
93-
94-
To learn about assembling an aggregation pipeline and view examples, see
95-
:manual:`Aggregation Pipeline </core/aggregation-pipeline/>` in the
96-
Server manual.
97-
98-
To learn more about creating pipeline stages, see :manual:`Aggregation
99-
Stages </reference/operator/aggregation-pipeline/>` in the Server manual.
100-
101-
Runnable Examples
102-
-----------------
103-
104-
The example uses sample data about restaurants. The following code
105-
inserts data into the ``restaurants`` collection of the ``aggregation``
106-
database:
107-
108-
.. literalinclude:: /code-snippets/aggregation/agg.js
109-
:start-after: begin data insertion
110-
:end-before: end data insertion
111-
:language: javascript
112-
:dedent:
113-
114-
.. tip::
115-
116-
For more information on connecting to your MongoDB deployment, see the :doc:`Connection Guide </connect>`.
117-
118-
Aggregation Example
119-
~~~~~~~~~~~~~~~~~~~
120-
121-
To perform an aggregation, pass a list of aggregation stages to the
122-
``collection.aggregate()`` method.
123-
124-
In the example, the aggregation pipeline uses the following aggregation stages:
125-
126-
- A :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents whose
127-
``categories`` array field contains the element ``Bakery``.
128-
129-
- A :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching documents by the ``stars``
130-
field, accumulating a count of documents for each distinct value of ``stars``.
131-
132-
.. literalinclude:: /code-snippets/aggregation/agg.js
133-
:start-after: begin aggregation
134-
:end-before: end aggregation
135-
:language: javascript
136-
:dedent:
137-
138-
This example produces the following output:
139-
140-
.. code-block:: json
141-
:copyable: false
142-
143-
{ _id: 4, count: 2 }
144-
{ _id: 3, count: 1 }
145-
{ _id: 5, count: 1 }
101+
- Pipeline stages have a memory limit of 100 megabytes by default. If required,
102+
you can exceed this limit by enabling the `AllowDiskUse
103+
<https://mongodb.github.io/node-mongodb-native/6.17/interfaces/AggregateOptions.html#allowDiskUse>`__
104+
property of the ``AggregateOptions`` object that you pass to the
105+
``Aggregate()`` method.
146106

147-
For more information, see the `aggregate() API documentation <{+api+}/classes/Collection.html#aggregate>`__.
107+
Additional information
108+
----------------------
148109

149-
Additional Examples
150-
~~~~~~~~~~~~~~~~~~~
110+
To view a full list of expression operators, see
111+
:manual:`Aggregation Operators </reference/operator/aggregation/>`.
151112

152-
You can find another aggregation pipeline example in the `Aggregation
153-
Framework with Node.js Tutorial
154-
<https://www.mongodb.com/blog/post/quick-start-nodejs--mongodb--how-to-analyze-data-using-the-aggregation-framework>`_
155-
blog post on the MongoDB website.
113+
To learn about explaining MongoDB aggregation operations, see
114+
:manual:`Explain Results </reference/explain-results/>` and
115+
:manual:`Query Plans </core/query-plans/>`.

0 commit comments

Comments
 (0)