Skip to content

Commit 7d803d0

Browse files
committed
Address RR feedback
1 parent 1cf7cfb commit 7d803d0

File tree

2 files changed

+57
-48
lines changed

2 files changed

+57
-48
lines changed

source/aggregation.txt

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ Overview
3030
In this guide, you can learn how to use the {+driver-short+} to perform
3131
**aggregation operations**.
3232

33-
Aggregation operations process data in your MongoDB collections and
33+
You can use aggregation operations to process data in your MongoDB collections and
3434
return computed results. The MongoDB Aggregation framework, which is
35-
part of the Query API, is modeled on the concept of data processing
36-
pipelines. Documents enter a pipeline that contains one or more stages,
37-
and this pipeline transforms the documents into an aggregated result.
35+
part of the Query API, is modeled on the concept of a data processing
36+
pipeline. Documents enter a pipeline that contains one or more stages,
37+
and each stage transforms the documents to output a final aggregated result.
3838

39-
An aggregation operation is similar to a car factory. A car factory has
39+
You can think of an aggregation operation as similar to a car factory. A car factory has
4040
an assembly line, which contains assembly stations with specialized
4141
tools to do specific jobs, like drills and welders. Raw parts enter the
4242
factory, and then the assembly line transforms and assembles them into a
@@ -46,8 +46,8 @@ The **aggregation pipeline** is the assembly line, **aggregation stages** are th
4646
assembly stations, and **operator expressions** are the
4747
specialized tools.
4848

49-
Aggregation Versus Find Operations
50-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49+
Compare Aggregation and Find Operations
50+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5151

5252
You can use find operations to perform the following actions:
5353

@@ -66,20 +66,19 @@ You can use aggregation operations to perform the following actions:
6666
Limitations
6767
~~~~~~~~~~~
6868

69-
Keep the following limitations in mind when using aggregation operations:
69+
The following limitations apply when using aggregation operations:
7070

7171
- Returned documents must not violate the
7272
:manual:`BSON document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>`
7373
of 16 megabytes.
7474
- Pipeline stages have a memory limit of 100 megabytes by default. You can exceed this
75-
limit by using the ``allowDiskUse`` method of the
76-
``AggregateIterable`` type.
75+
limit by using the ``allowDiskUse()`` method from ``AggregateIterable`` class.
7776

7877
.. important:: $graphLookup exception
7978

8079
The :manual:`$graphLookup
8180
</reference/operator/aggregation/graphLookup/>` stage has a strict
82-
memory limit of 100 megabytes and ignores the ``allowDiskUse`` parameter.
81+
memory limit of 100 megabytes and ignores the ``allowDiskUse`` option.
8382

8483
Aggregation Example
8584
-------------------
@@ -100,18 +99,27 @@ The following {+language+} data class models the documents in this collection:
10099
Build and Execute an Aggregation Pipeline
101100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102101

103-
To perform an aggregation, pass a list of aggregation stages to the
104-
``collection.aggregate()`` method.
102+
To perform an aggregation on the documents in a collection, pass a list of aggregation
103+
stages to the ``aggregate()`` method.
105104

106-
The following code example produces a count of the number of bakeries in each borough
107-
of New York. To do so, it uses an aggregation pipeline with the following stages:
105+
This example outputs a count of the number of bakeries in each borough
106+
of New York City. The following code creates aggregation pipeline that contains the
107+
following stages:
108108

109109
- A :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents
110-
whose ``cuisine`` field contains the value ``"Bakery"``.
110+
in which the value of the ``cuisine`` field is ``"Bakery"``.
111111

112112
- A :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching
113-
documents by the ``borough`` field, accumulating a count of documents for each distinct
114-
value.
113+
documents by the ``borough`` field, producing a count of documents for each distinct
114+
value of that field.
115+
116+
.. TODO: uncomment when Aggregates Builder page is created
117+
118+
.. .. note::
119+
120+
.. The following example uses the builders pattern to implement the stages of an
121+
.. aggregation pipeline. To learn more about how to use the builders pattern, see
122+
.. :ref:`<aggregates-builders>`
115123

116124
.. io-code-block::
117125

@@ -131,18 +139,23 @@ of New York. To do so, it uses an aggregation pipeline with the following stages
131139
Document{{_id=Staten Island, count=20}}
132140
Document{{_id=Missing, count=2}}
133141

142+
.. tip::
143+
144+
When specifying a group key for the ``$group`` aggregation stage, ensure that you
145+
escape any ``$`` characters by using the ``\`` character.
146+
134147
Explain an Aggregation
135148
~~~~~~~~~~~~~~~~~~~~~~
136149

137150
To view information about how MongoDB executes your operation, you can
138-
instruct MongoDB to **explain** it. When MongoDB explains an operation, it returns
139-
**execution plans** and performance statistics. An execution
151+
include the ``$explain`` aggregation stage in your pipeline. When MongoDB explains an
152+
operation, it returns **execution plans** and performance statistics. An execution
140153
plan is a potential way MongoDB can complete an operation.
141154
When you instruct MongoDB to explain an operation, it returns both the
142-
plan MongoDB executed and any rejected execution plans.
155+
plan MongoDB selected for the operation and any rejected execution plans.
143156

144-
The following code example runs the preceding aggregation example and prints the returned
145-
explanation:
157+
The following code example runs the same aggregation shown in the preceding section
158+
and adds the ``$explain`` stage to output the operation details:
146159

147160
.. io-code-block::
148161

@@ -156,43 +169,39 @@ explanation:
156169
:visible: false
157170

158171
{
159-
"explain": {
160-
"aggregate": "restaurants",
161-
"pipeline": [
162-
{
163-
"$match": {
164-
"cuisine": "Bakery"
165-
}
166-
},
167-
{
168-
"$group": {
169-
"_id": "$borough",
170-
"count": {
171-
"$sum": 1
172-
}
173-
}
174-
}
175-
],
176-
"cursor": {}
177-
},
178-
...
172+
"explainVersion": "2",
173+
"queryPlanner": {
174+
"namespace": "sample_restaurants.restaurants"
175+
"indexFilterSet": false,
176+
"parsedQuery": {
177+
"cuisine": {"$eq": "Bakery"}
178+
},
179+
"queryHash": "865F14C3",
180+
"planCacheKey": "0697561B",
181+
"optimizedPipeline": true,
182+
"maxIndexedOrSolutionsReached": false,
183+
"maxIndexedAndSolutionsReached": false,
184+
"maxScansToExplodeReached": false,
185+
"winningPlan": { ... }
186+
...
187+
}
179188
}
180189

181190
Additional Information
182191
----------------------
183192

184193
To view a full list of expression operators, see :manual:`Aggregation
185-
Operators. </reference/operator/aggregation/>`
194+
Operators </reference/operator/aggregation/>` in the {+mdb-server+} manual.
186195

187196
To learn about assembling an aggregation pipeline and view examples, see
188-
:manual:`Aggregation Pipeline. </core/aggregation-pipeline/>`
197+
:manual:`Aggregation Pipeline </core/aggregation-pipeline/>` in the {+mdb-server+} manual.
189198

190199
To learn more about creating pipeline stages, see :manual:`Aggregation
191-
Stages. </reference/operator/aggregation-pipeline/>`
200+
Stages </reference/operator/aggregation-pipeline/>` in the {+mdb-server+} manual.
192201

193202
To learn more about explaining MongoDB operations, see
194203
:manual:`Explain Output </reference/explain-results/>` and
195-
:manual:`Query Plans. </core/query-plans/>`
204+
:manual:`Query Plans </core/query-plans/>` in the {+mdb-server+} manual.
196205

197206
.. Aggregation Tutorials
198207
.. ~~~~~~~~~~~~~~~~~~~~~

source/index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ section.
8282
Transform Your Data with Aggregation
8383
------------------------------------
8484

85-
Learn how to use the {+driver-short+} to perform aggregation operatoins in the
85+
Learn how to use the {+driver-short+} to perform aggregation operations in the
8686
:ref:`kotlin-sync-aggregation` section.
8787

8888
Specialized Data Formats

0 commit comments

Comments
 (0)