Skip to content

Commit 44b00b4

Browse files
committed
MM PR fixes 1
1 parent c88382d commit 44b00b4

File tree

2 files changed

+45
-43
lines changed

2 files changed

+45
-43
lines changed

source/aggregation/agg-exp-ops.txt

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _kotlin-sync-sync-aggregation-expression-operations:
1+
.. _kotlin-sync-aggregation-expression-operations:
22

33
=================================
44
Aggregation Expression Operations
@@ -72,13 +72,13 @@ value of ``1.0``:
7272
of(1.0)
7373

7474
To create an operation, chain a method to your field or value reference.
75-
You can build more complex operations by chaining other methods.
75+
You can build more complex operations by chaining multiple methods.
7676

7777
The following example creates an operation to find patients in New
7878
Mexico who have visited the doctor’s office at least once. The operation
7979
performs the following actions:
8080

81-
- Checks if the size of the ``visitDates`` array is greater than ``0``
81+
- Checks if the size of the ``visitDates`` array value is greater than ``0``
8282
by using the ``gt()`` method
8383
- Checks if the ``state`` field value is “New Mexico” by using the
8484
``eq()`` method
@@ -112,11 +112,7 @@ how to include your expression in common aggregates builder methods:
112112
- ``group(<expression>)``
113113

114114
.. TODO To learn more about these methods, see the
115-
.. :ref:`kotlin-sync-sync-aggregation`.
116-
117-
The examples use the ``listOf()`` method to create a list of
118-
aggregation stages. Then, the examples pass the pipeline to the
119-
``aggregate()`` method of ``MongoCollection``.
115+
.. :ref:`kotlin-sync-aggregation`.
120116

121117
Constructor Methods
122118
-------------------
@@ -195,6 +191,10 @@ the Server manual documentation. While each method is effectively
195191
equivalent to the corresponding Query API expression, they may differ in
196192
expected parameters and implementation.
197193

194+
The example in each section uses the ``listOf()`` method to create a
195+
pipeline from the aggregation stage. Then, each example passes the
196+
pipeline to the ``aggregate()`` method of ``MongoCollection``.
197+
198198
.. note::
199199

200200
The driver generates a Query API expression that may be different
@@ -250,8 +250,8 @@ You can perform an arithmetic operation on a value of type ``MqlInteger`` or
250250
- :manual:`$subtract </reference/operator/aggregation/subtract/>`
251251

252252
Suppose you have weather data for a specific year that includes the
253-
precipitation measurement (in inches) for each day. You want find the average
254-
precipitation, in millimeters, for each month.
253+
precipitation measurement (in inches) for each day. You want to find the
254+
average precipitation, in millimeters, for each month.
255255

256256
The ``multiply()`` operator multiplies the ``precipitation`` field by
257257
``25.4`` to convert the value to millimeters. The ``avg()`` accumulator method
@@ -389,18 +389,20 @@ following:
389389
The ``filter()`` method displays only the results matching the provided
390390
predicate. In this case, the predicate uses ``sum()`` to calculate the
391391
total number of seats and compares that value to the number of ``ticketsBought``
392-
with ``lt()``. The ``project()`` method stores these filtered results as a new
393-
``availableShowtimes`` array.
392+
by using the ``lt()`` method. The ``project()`` method stores these
393+
filtered results as a new ``availableShowtimes`` array field.
394394

395395
.. tip::
396396

397-
You must specify the type of the array that you retrieve with the
398-
``getArray()`` method if you work with the values of the
399-
array as their specific type.
397+
You must specify the type of values that an array contains when using
398+
the ``getArray()`` method to work with the values as any specific
399+
type. For example, you must specify that an array contains integers
400+
if you want to perform calculations with those integers elsewhere in
401+
your application.
400402

401-
In this example, we specify that the ``seats`` array contains values
402-
of type ``MqlDocument`` so that we can extract nested fields from
403-
each array entry.
403+
The example in this section specifies that the ``seats`` array
404+
contains values of type ``MqlDocument`` so that it can extract nested
405+
fields from each array entry.
404406

405407
The following code shows the pipeline for this aggregation:
406408

@@ -414,8 +416,8 @@ The following code shows the pipeline for this aggregation:
414416
.. note::
415417

416418
To improve readability, the previous example assigns intermediary values to
417-
the ``totalSeats`` and ``isAvailable`` variables. If you don't pull
418-
out these intermediary values into variables, the code still produces
419+
the ``totalSeats`` and ``isAvailable`` variables. If you don't assign
420+
these intermediary values to variables, the code still produces
419421
equivalent results.
420422

421423
The following code provides an equivalent aggregation pipeline in
@@ -459,8 +461,9 @@ Suppose you want to classify very low or high weather temperature
459461
readings (in degrees Fahrenheit) as extreme.
460462

461463
The ``or()`` operator checks to see if temperatures are extreme by comparing
462-
the ``temperature`` field to predefined values with ``lt()`` and ``gt()``.
463-
The ``project()`` method records this result in the ``extremeTemp`` field.
464+
the ``temperature`` field to predefined values by using the ``lt()`` and
465+
``gt()`` methods. The ``project()`` method records this result in the
466+
``extremeTemp`` field.
464467

465468
The following code shows the pipeline for this aggregation:
466469

@@ -675,13 +678,12 @@ how the values compare:
675678

676679
.. tip::
677680

678-
One advantage of using the ``passTo()`` method is that you can reuse
679-
your custom methods for other aggregations. You could
681+
Using the ``passTo()`` method allows you to reuse
682+
your custom methods for other aggregations. For example, you can
680683
use the ``gradeAverage()`` method to find the average of grades for
681684
groups of students filtered by entry year or district, not just their
682-
class, for example. You could use the ``evaluate()`` method to evaluate, for
683-
example, an individual student's performance, or an entire school's or
684-
district's performance.
685+
class. Similarly, you could use the ``evaluate()`` method to evaluate
686+
an individual student's performance or an entire school's performance.
685687

686688
The ``passArrayTo()`` method takes an array of all students and calculates the
687689
average score by using the ``gradeAverage()`` method. Then, the
@@ -832,10 +834,10 @@ valid dates, such as ``"2018-01-15T16:00:00Z"`` or ``"Jan 15, 2018, 12:00
832834
PM EST"``, you can use the ``parseDate()`` method to convert the strings
833835
into date types.
834836

835-
The ``dayOfWeek()`` method determines which day of the week it is and converts
836-
it to a number based on which day is a Monday according to the
837-
``"America/New_York"`` parameter. The ``eq()`` method compares this value to
838-
``2``, which corresponds to Monday based on the provided timezone parameter.
837+
The ``dayOfWeek()`` method determines which day of the week that a date
838+
is, then converts it to a number. The number assignment uses ``0`` to mean
839+
Sunday when using the ``"America/New_York"`` timezone. The ``eq()``
840+
method compares this value to ``2``, or Monday.
839841

840842
The following code shows the pipeline for this aggregation:
841843

source/includes/aggregation/aggExpressions.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AggExpressionsTest {
4040
val month = current().getDate("date").month(of("UTC"))
4141
val precip = current().getInteger("precipitation")
4242

43-
val results = collection.aggregate<Document>( // :remove:
43+
val results = collection.aggregate<Document>(
4444
listOf(
4545
Aggregates.group(
4646
month,
@@ -89,7 +89,7 @@ class AggExpressionsTest {
8989
// start-array-aggregation
9090
val showtimes = current().getArray<MqlDocument>("showtimes")
9191

92-
val results = collection.aggregate<Document>( // :remove:
92+
val results = collection.aggregate<Document>(
9393
listOf(
9494
Aggregates.project(
9595
Projections.fields(
@@ -131,7 +131,7 @@ class AggExpressionsTest {
131131
// start-boolean-aggregation
132132
val temperature = current().getInteger("temperature")
133133

134-
val results = collection.aggregate<Document>( // :remove:
134+
val results = collection.aggregate<Document>(
135135
listOf(
136136
Aggregates.project(
137137
Projections.fields(
@@ -172,7 +172,7 @@ class AggExpressionsTest {
172172
// start-comparison-aggregation
173173
val location = current().getString("location")
174174

175-
val results = collection.aggregate<Document>( // :remove:
175+
val results = collection.aggregate<Document>(
176176
listOf(
177177
Aggregates.match(
178178
Filters.expr(location.eq(of("California")))
@@ -206,7 +206,7 @@ class AggExpressionsTest {
206206
// start-conditional-aggregation
207207
val member = current().getField("member")
208208

209-
val results = collection.aggregate<Document>( // :remove:
209+
val results = collection.aggregate<Document>(
210210
listOf(
211211
Aggregates.project(
212212
Projections.fields(
@@ -272,7 +272,7 @@ class AggExpressionsTest {
272272
// start-convenience-aggregation
273273
val students = current().getArray<MqlDocument>("students")
274274

275-
val results = collection.aggregate<Document>( // :remove:
275+
val results = collection.aggregate<Document>(
276276
listOf(
277277
Aggregates.project(
278278
Projections.fields(
@@ -311,7 +311,7 @@ class AggExpressionsTest {
311311
// start-conversion-aggregation
312312
val graduationYear = current().getString("graduationYear")
313313

314-
val results = collection.aggregate<Document>( // :remove:
314+
val results = collection.aggregate<Document>(
315315
listOf(
316316
Aggregates.addFields(
317317
Field(
@@ -351,7 +351,7 @@ class AggExpressionsTest {
351351
// start-date-aggregation
352352
val deliveryDate = current().getString("deliveryDate")
353353

354-
val results = collection.aggregate<Document>( // :remove:
354+
val results = collection.aggregate<Document>(
355355
listOf(
356356
Aggregates.match(
357357
Filters.expr(
@@ -393,7 +393,7 @@ class AggExpressionsTest {
393393
// start-document-aggregation
394394
val address = current().getDocument("mailing.address")
395395

396-
val results = collection.aggregate<Document>( // :remove:
396+
val results = collection.aggregate<Document>(
397397
listOf(
398398
Aggregates.match(
399399
Filters.expr(
@@ -427,7 +427,7 @@ class AggExpressionsTest {
427427
// start-map-aggregation
428428
val warehouses = current().getMap<MqlNumber>("warehouses")
429429

430-
val results = collection.aggregate<Document>( // :remove:
430+
val results = collection.aggregate<Document>(
431431
listOf(
432432
Aggregates.project(
433433
Projections.fields(
@@ -465,7 +465,7 @@ class AggExpressionsTest {
465465
val lastName = current().getString("lastName")
466466
val employeeID = current().getString("employeeID")
467467

468-
val results = collection.aggregate<Document>( // :remove:
468+
val results = collection.aggregate<Document>(
469469
listOf(
470470
Aggregates.project(
471471
Projections.fields(
@@ -504,7 +504,7 @@ class AggExpressionsTest {
504504
// start-type-aggregation
505505
val rating = current().getField("rating")
506506

507-
val results = collection.aggregate<Document>( // :remove:
507+
val results = collection.aggregate<Document>(
508508
listOf(
509509
Aggregates.project(
510510
Projections.fields(

0 commit comments

Comments
 (0)