@@ -89,69 +89,226 @@ Limitations
89
89
Create an Aggregation Pipeline
90
90
------------------------------
91
91
92
- Aggregation pipelines can be created in two seperate modes :
92
+ |compass| provides different modes to create aggregation pipelines :
93
93
94
- - Stage View Mode, a visual click-based pipeline editor that
95
- preloads pipeline syntax based on your selected stages.
94
+ - Stage View Mode, a visual pipeline editor that preloads pipeline syntax based
95
+ on your selected stages.
96
+
97
+ - Focus Mode, a feature of Stage View Mode where you edit one pipeline stage at
98
+ a time. Focus Mode helps you manage complex or deeply nested aggregation
99
+ pipeline stages.
96
100
97
101
- Text View Mode, a text-based pipeline editor that accepts raw
98
102
pipeline syntax.
99
103
100
- .. _create-agg-pipeline-stageview:
101
-
102
- Stage View Mode
103
- ~~~~~~~~~~~~~~~
104
- |
105
-
106
- .. include:: /includes/steps/create-agg-pipeline.rst
107
-
108
- .. _create-agg-pipeline-textview:
109
-
110
- Text View Mode
111
- ~~~~~~~~~~~~~~
112
- |
113
-
114
- .. procedure::
115
- :style: normal
116
-
117
- .. step:: In the aggregation pipeline pane, click the
118
- :guilabel:`</> Text` toggle switch to enable text mode for
119
- pipeline editing.
120
-
121
- .. figure:: /images/compass/agg-builder-textview-toggle-on.png
122
- :alt: Toggle textmode on
123
-
124
- .. step:: Enter valid aggregation syntax in the text editor.
125
- The following example pipeline limits the query results to ``4``
126
- documents.
127
-
128
- .. code-block:: javascript
129
-
130
- [ { "$limit" : 4 } ]
131
-
132
- .. figure:: /images/compass/agg-builder-textview-edit.png
133
- :alt: Edit the text aggregation pipeline
134
-
135
- .. step:: **(Optional)** If preview mode is enabled, you can
136
- click :guilabel:`Output Options` in the Pipeline Output pane to
137
- expand all nested fields and documents within the
138
- preview results.
139
-
140
- .. figure:: /images/compass/agg-builder-textview-expand-pipeline-preview.png
141
- :alt: Pipeline Output preview
142
-
143
- .. step:: Click :guilabel:`Run` at the top right of the pipeline builder.
144
- |compass-short| returns your results in the document view.
145
-
146
- .. figure:: /images/compass/agg-builder-textview-agg-results.png
147
- :alt: Results after Running Aggregation
148
-
149
- .. step:: **(Optional)** Click the :guilabel:`Output Options` dropdown
150
- and select :guilabel:`Expand all fields` to expand all nested
151
- fields and documents within the query results.
152
-
153
- .. figure:: /images/compass/agg-builder-textview-expand-results.png
154
- :alt: Expand the aggregation pipeline results
104
+ To see how to create an aggregation pipeline, select the tab corresponding to
105
+ your chosen view mode:
106
+
107
+ .. tabs::
108
+
109
+ .. tab:: Stage View Mode
110
+ :tabid: stage
111
+
112
+ .. procedure::
113
+ :style: normal
114
+
115
+ .. step:: In the aggregation pipeline pane, ensure the
116
+ :guilabel:`{} Stages` toggle switch is selected.
117
+
118
+ .. figure:: /images/compass/agg-builder-stageview-toggle-on.png
119
+ :alt: Toggle on stage view mode
120
+
121
+ .. step:: At the bottom of the aggregation pipeline pane, select the
122
+ :guilabel:`+ Add Stage` button to open a new aggregation stage
123
+ modal.
124
+
125
+ .. step:: At the lower-left corner of the aggregation pipeline pane,
126
+ click the :guilabel:`Select...` dropdown and select the
127
+ :manual:`aggregation pipeline stage
128
+ </reference/operator/aggregation-pipeline/>` to use for the first
129
+ stage of the pipeline.
130
+
131
+ .. step:: Fill in your selected pipeline stage.
132
+
133
+ If you enable :guilabel:`Preview`, preview documents update
134
+ automatically to the right of the stage to reflect the results of
135
+ your pipeline as it progresses. You can adjust the width of the
136
+ pipeline stage by dragging its border to the right.
137
+
138
+ .. figure:: /images/compass/agg-builder-match-stage.png
139
+ :alt: Aggregation Builder match stage example
140
+
141
+ .. step:: Click :guilabel:`Add Stage` to add additional aggregation
142
+ stages below your most recently added aggregation stage. Repeat
143
+ steps 1 and 2 for each additional stage.
144
+
145
+ .. note::
146
+
147
+ .. include:: /includes/fact-agg-pipeline-preview-toggle.rst
148
+
149
+ For example, the following pipeline excludes the first
150
+ :manual:`$match </reference/operator/aggregation/match/>` stage
151
+ and only includes the
152
+ :manual:`$project </reference/operator/aggregation/project/>`
153
+ stage:
154
+
155
+ .. figure:: /images/compass/agg-builder-exclude-stage-example.png
156
+ :alt: Aggregation Builder exclude stage example
157
+
158
+ .. step:: Click :guilabel:`Run` at the top right of the pipeline
159
+ builder. |compass-short| returns your results in the document view.
160
+
161
+ .. warning::
162
+
163
+ When you click :guilabel:`Run`, the aggregation runs against the
164
+ entire collection.
165
+
166
+ .. step:: To edit the pipeline, click :guilabel:`Edit` at the top of
167
+ your pipeline toolbar to return to the aggregation pipeline builder
168
+ and make changes to your pipeline.
169
+
170
+ .. tab:: Focus Mode
171
+ :tabid: focus
172
+
173
+ .. procedure::
174
+ :style: normal
175
+
176
+ .. step:: Select the :guilabel:`Stages` view.
177
+
178
+ In the aggregation pipeline pane, ensure the
179
+ :guilabel:`{} Stages` toggle switch is selected.
180
+
181
+ .. figure:: /images/compass/agg-builder-stageview-toggle-on.png
182
+ :alt: Toggle on stage view mode
183
+
184
+ .. step:: Add an aggregation stage.
185
+
186
+ If you have not already created an aggregation stage, click the
187
+ :guilabel:`+ Add Stage` button at the bottom of the aggregation
188
+ pipeline pane.
189
+
190
+ .. step:: Open Focus Mode.
191
+
192
+ On the upper-right corner of the stage card, click the
193
+ Focus Mode icon.
194
+
195
+ .. figure:: /images/compass/focus-mode-button.png
196
+ :alt: Select the Focus Mode button
197
+
198
+ .. step:: Select an aggregation pipeline stage.
199
+
200
+ Click the :guilabel:`Select` dropdown and select the
201
+ :manual:`aggregation pipeline stage
202
+ </reference/operator/aggregation-pipeline/>` to use for the first
203
+ stage of the pipeline.
204
+
205
+ .. step:: Fill in your pipeline stage.
206
+
207
+ Fill in your selected stage. |compass-short| populates the
208
+ :guilabel:`Stage Output` with up to ten sample output documents.
209
+
210
+ You can adjust the width of the :guilabel:`Stage Input`, stage
211
+ editor, and the :guilabel:`Stage Output` by dragging their border to
212
+ the desired size.
213
+
214
+ .. note::
215
+
216
+ .. include:: /includes/fact-agg-pipeline-preview-toggle.rst
217
+
218
+ .. step:: Add additional pipeline stages.
219
+
220
+ Click the :guilabel:`Add Stage` dropdown to add additional
221
+ aggregation stages before or after your last aggregation stage.
222
+ Repeat steps 4 and 5 for each additional stage.
223
+
224
+ You can add stages with the following keyboard shortcuts:
225
+
226
+ - To add a stage after the current stage:
227
+
228
+ - Windows / Linux: :guilabel:`Ctrl + Shift + A`
229
+
230
+ - Mac: :guilabel:`⌘ + Shift + A`
231
+
232
+ - To add a stage before the current stage:
233
+
234
+ - Windows / Linux: :guilabel:`Ctrl + Shift + B`
235
+
236
+ - Mac: :guilabel:`⌘ + Shift + B`
237
+
238
+ .. step:: Navigate between stages.
239
+
240
+ To navigate between different stages, select the stage you
241
+ want to edit from the :guilabel:`Stage` dropdown in the upper-right
242
+ corner of the Focus Mode modal.
243
+
244
+ You can navigate between stages with the following keyboard
245
+ shortcuts:
246
+
247
+ - To go to the stage before the current stage:
248
+
249
+ - Windows / Linux: :guilabel:`Ctrl + Shift + 9`
250
+
251
+ - Mac: :guilabel:`⌘ + Shift + 9`
252
+
253
+ - To add a stage before the current stage:
254
+
255
+ - Windows / Linux: :guilabel:`Ctrl + Shift + 0`
256
+
257
+ - Mac: :guilabel:`⌘ + Shift + 0`
258
+
259
+ .. step:: Run the pipeline.
260
+
261
+ Click :guilabel:`x` to exit Focus Mode and select
262
+ :guilabel:`Run` at the top right of the pipeline builder.
263
+ |compass-short| returns your results in the document view.
264
+
265
+ .. tab:: Text View Mode
266
+ :tabid: text
267
+
268
+ .. procedure::
269
+ :style: normal
270
+
271
+ .. step:: Select the :guilabel:`Text` view.
272
+
273
+ In the aggregation pipeline pane, click the
274
+ :guilabel:`</> Text` toggle switch to enable text mode for pipeline
275
+ editing.
276
+
277
+ .. figure:: /images/compass/agg-builder-textview-toggle-on.png
278
+ :alt: Toggle textmode on
279
+
280
+ .. step:: Enter your aggregation pipeline.
281
+
282
+ Enter valid aggregation syntax in the text editor. The
283
+ following example pipeline limits the query results to ``4``
284
+ documents.
285
+
286
+ .. code-block:: javascript
287
+
288
+ [ { "$limit" : 4 } ]
289
+
290
+ .. note::
291
+
292
+ To expand all embedded fields and documents within the preview
293
+ results, click :guilabel:`Output Options` and select
294
+ :guilabel:`Expand all fields`.
295
+
296
+ .. figure:: /images/compass/agg-builder-textview-expand-pipeline-preview.png
297
+ :alt: Pipeline Output preview
298
+
299
+ .. step:: Run the pipeline.
300
+
301
+ Click :guilabel:`Run` at the top right of the pipeline
302
+ builder. |compass-short| returns your results in the document view.
303
+
304
+ .. note::
305
+
306
+ To expand all embedded fields and documents within the preview
307
+ results, click :guilabel:`Output Options` and select
308
+ :guilabel:`Expand all fields`.
309
+
310
+ .. figure:: /images/compass/agg-builder-textview-expand-results.png
311
+ :alt: Expand the aggregation pipeline results
155
312
156
313
.. _save-agg-pipeline:
157
314
0 commit comments