@@ -49,7 +49,7 @@ Aggregation operations have some :manual:`limitations </core/aggregation-pipelin
49
49
of 16 megabytes.
50
50
51
51
- Pipeline stages have a memory limit of 100 megabytes by default. If required, you may exceed this limit by using
52
- the `allowDiskUse <https://mongodb.github.io/mongo-java-driver/4.2/ apidocs/mongodb-driver-sync/com/mongodb/client/AggregateIterable.html#allowDiskUse(java.lang.Boolean)>`__
52
+ the :java-docs: `allowDiskUse <apidocs/mongodb-driver-sync/com/mongodb/client/AggregateIterable.html#allowDiskUse(java.lang.Boolean)>`
53
53
method.
54
54
55
55
.. important:: ``$graphLookup`` exception
@@ -116,20 +116,17 @@ Basic Aggregation Example
116
116
~~~~~~~~~~~~~~~~~~~~~~~~~
117
117
118
118
To perform an aggregation, pass a list of aggregation stages to the
119
- :java-docs:`MongoCollection.aggregate() <apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`
120
- method.
119
+ ``MongoCollection.aggregate()`` method.
121
120
122
121
The Java driver provides the
123
122
:java-docs:`Aggregates <apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html>`
124
- helper class that
125
- contains builders for aggregation stages.
123
+ helper class that contains builders for aggregation stages.
126
124
127
125
In the following example, the aggregation pipeline:
128
126
129
127
- Uses a :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents whose
130
128
``categories`` array field contains the element ``Bakery``. The example uses
131
- :java-docs:`Aggregates.match <apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#match(org.bson.conversions.Bson)>`
132
- to build the ``$match`` stage.
129
+ ``Aggregates.match`` to build the ``$match`` stage.
133
130
134
131
- Uses a :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching documents by the ``stars``
135
132
field, accumulating a count of documents for each distinct value of ``stars``.
@@ -152,6 +149,12 @@ The above aggregation should produce the following results:
152
149
{"_id": 4, "count": 2}
153
150
{"_id": 5, "count": 1}
154
151
152
+ For more information about the methods and classes mentioned in this section,
153
+ see the following API Documentation:
154
+
155
+ - :java-docs:`MongoCollection.aggregate() <apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`
156
+ - :java-docs:`Aggregates.match <apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#match(org.bson.conversions.Bson)>`
157
+
155
158
Explain Aggregation Example
156
159
~~~~~~~~~~~~~~~~~~~~~~~~~~~
157
160
@@ -191,18 +194,16 @@ following resources:
191
194
192
195
- :manual:`Explain Output </reference/explain-results/>` Server Manual Entry
193
196
- :manual:`Query Plans </core/query-plans/>` Server Manual Entry
194
- - :java-core-api :`ExplainVerbosity <com/mongodb/ExplainVerbosity>` API Documentation
197
+ - :java-docs :`ExplainVerbosity <apidocs/mongodb-driver-core/ com/mongodb/ExplainVerbosity>` API Documentation
195
198
- :java-docs:`explain() <apidocs/mongodb-driver-sync/com/mongodb/client/FindIterable.html#explain()>` API Documentation
196
199
- :java-docs:`AggregateIterable <apidocs/mongodb-driver-sync/com/mongodb/client/AggregateIterable.html>` API Documentation
197
200
198
201
Aggregation Expression Example
199
202
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200
203
201
- The Java driver provides builders for
202
- :java-docs:`accumulator expressions <apidocs/mongodb-driver-core/com/mongodb/client/model/Accumulators.html>`
203
- for use with
204
- :java-docs:`$group <apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#group(TExpression,java.util.List)>`. You
205
- must declare all other expressions in JSON format or compatible document format.
204
+ The Java driver provides builders for accumulator expressions for use with
205
+ ``$group``. You must declare all other expressions in JSON format or
206
+ compatible document format.
206
207
207
208
.. tip::
208
209
@@ -223,19 +224,16 @@ must declare all other expressions in JSON format or compatible document format.
223
224
Document.parse("{ $arrayElemAt: ['$categories', 0] }")
224
225
225
226
In the following example, the aggregation pipeline uses a
226
- `$project <https://mongodb.github.io/mongo-java-driver/4.2/apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#project(org.bson.conversions.Bson)>`__
227
- stage and various
228
- `Projections <https://mongodb.github.io/mongo-java-driver/4.2/apidocs/mongodb-driver-core/com/mongodb/client/model/Projections.html>`__
229
- to return the ``name`` field and the calculated field ``firstCategory`` whose value is the first element in the
230
- ``categories`` field.
227
+ ``$project`` stage and various ``Projections`` to return the ``name``
228
+ field and the calculated field ``firstCategory`` whose value is the
229
+ first element in the ``categories`` field.
231
230
232
231
.. literalinclude:: /includes/fundamentals/code-snippets/AggTour.java
233
232
:language: java
234
233
:dedent:
235
234
:start-after: begin aggregation two
236
235
:end-before: end aggregation two
237
236
238
-
239
237
The above aggregation should produce the following results:
240
238
241
239
.. code-block:: none
@@ -251,3 +249,11 @@ The above aggregation should produce the following results:
251
249
{"name": "ZZZ Pasta Buffet", "firstCategory": "Pasta"}
252
250
{"name": "XYZ Coffee Bar", "firstCategory": "Coffee"}
253
251
{"name": "XYZ Bagels Restaurant", "firstCategory": "Bagels"}
252
+
253
+ For more information about the methods and classes mentioned in this section,
254
+ see the following API Documentation:
255
+
256
+ - :java-docs:`Accumulators <apidocs/mongodb-driver-core/com/mongodb/client/model/Accumulators.html>`
257
+ - :java-docs:`$group <apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#group(TExpression,java.util.List)>`
258
+ - :java-docs:`$project <apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#project(org.bson.conversions.Bson)>`
259
+ - :java-docs:`Projections <apidocs/mongodb-driver-core/com/mongodb/client/model/Projections.html>`
0 commit comments