@@ -72,6 +72,7 @@ Consider the following limitations when performing aggregation operations:
7272- Returned documents cannot violate the
7373 :manual:`BSON document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>`
7474 of 16 megabytes.
75+
7576- Pipeline stages have a memory limit of 100 megabytes by default. You can exceed this
7677 limit by creating an options array that sets the ``allowDiskUse`` option to ``true``
7778 and passing the array to the ``MongoDB\Collection::aggregate()`` method.
@@ -89,9 +90,9 @@ The {+library-short+} provides the following APIs to create aggregation
8990pipelines:
9091
9192- :ref:`php-aggregation-array-api`: Create aggregation pipelines by
92- passing arrays that specify the aggregation operators and parameters
93+ passing arrays that specify the aggregation operators and parameters.
9394- :ref:`php-aggregation-builder-api`: Create aggregation pipelines by using native
94- classes and methods to make your application more type-safe and debuggable
95+ classes and methods to make your application more type-safe and debuggable.
9596
9697The following sections describe each API and provide examples for
9798creating aggregation pipelines.
@@ -126,12 +127,12 @@ Filter and Group Example
126127The following code example produces a count of the number of bakeries in each borough
127128of New York. To do so, it uses an aggregation pipeline that contains the following stages:
128129
129- - :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents
130- in which the ``cuisine`` field contains the value ``'Bakery'``
130+ 1. :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents
131+ in which the ``cuisine`` field contains the value ``'Bakery'``
131132
132- - :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching
133- documents by the ``borough`` field, accumulating a count of documents for each distinct
134- value
133+ #. :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching
134+ documents by the ``borough`` field, accumulating a count of documents for each distinct
135+ value
135136
136137.. io-code-block::
137138 :copyable:
@@ -195,14 +196,16 @@ Aggregation Builder
195196To create an aggregation pipeline by using the Aggregation Builder,
196197perform the following actions:
197198
198- # . Create an array to store the pipeline stages
199+ 1 . Create an array to store the pipeline stages.
199200
200- #. For each stage, call an operator method from the ``Stage``
201- builder class to create that type of aggregation stage
201+ #. For each stage, call the an operator method from the
202+ ``Stage`` that shares the same name as your desired aggregation
203+ stage. For example, to create an ``$unwind`` stage, call the
204+ ``Stage::unwind()`` method.
202205
203206#. Within the body of the ``Stage`` method, use methods from other
204207 builder classes such as ``Query``, ``Expression``, or ``Accumulator``
205- to express your aggregation specifications
208+ to express your aggregation specifications.
206209
207210The following code demonstrates the template for constructing
208211aggregation pipelines:
@@ -236,17 +239,17 @@ The following code example calculates the total sales amount, average
236239sales quantity, and sale count for each day in the year 2014. To do so,
237240it uses an aggregation pipeline that contains the following stages:
238241
239- - :manual:`$match </reference/operator/aggregation/match/>` stage to
240- filter for documents that contain a ``date`` field in which the year is
241- 2014
242+ 1. :manual:`$match </reference/operator/aggregation/match/>` stage to
243+ filter for documents that contain a ``date`` field in which the year is
244+ 2014
242245
243- - :manual:`$group </reference/operator/aggregation/group/>` stage to
244- group the documents by date and calculate the total sale amount,
245- average quantity, and total count for each group
246+ #. :manual:`$group </reference/operator/aggregation/group/>` stage to
247+ group the documents by date and calculate the total sale amount,
248+ average quantity, and total count for each group
246249
247- - :manual:`$sort </reference/operator/aggregation/sort/>` stage to
248- sort the results by the total sale amount for each group in descending
249- order
250+ #. :manual:`$sort </reference/operator/aggregation/sort/>` stage to
251+ sort the results by the total sale amount for each group in descending
252+ order
250253
251254.. io-code-block::
252255 :copyable:
@@ -275,15 +278,15 @@ The following code example groups sold items by their tags and
275278calculates the total sales amount for each tag. To do so,
276279it uses an aggregation pipeline that contains the following stages:
277280
278- - :manual:`$unwind </reference/operator/aggregation/unwind/>` stage to
279- output a separate document for each element in the ``items`` array
281+ 1. :manual:`$unwind </reference/operator/aggregation/unwind/>` stage to
282+ output a separate document for each element in the ``items`` array
280283
281- - :manual:`$unwind </reference/operator/aggregation/unwind/>` stage to
282- output a separate document for each element in the ``items.tags`` arrays
284+ #. :manual:`$unwind </reference/operator/aggregation/unwind/>` stage to
285+ output a separate document for each element in the ``items.tags`` arrays
283286
284- - :manual:`$group </reference/operator/aggregation/group/>` stage to
285- group the documents by the tag value and calculates the total sales
286- amount of items that have each tag
287+ #. :manual:`$group </reference/operator/aggregation/group/>` stage to
288+ group the documents by the tag value and calculates the total sales
289+ amount of items that have each tag
287290
288291.. io-code-block::
289292 :copyable:
0 commit comments