@@ -50,7 +50,6 @@ The :pipeline:`$out` stage has the following syntax:
50
50
- Description
51
51
52
52
* - :ref:`db <out-db>`
53
-
54
53
- .. _out-db:
55
54
56
55
The output database name.
@@ -63,7 +62,6 @@ The :pipeline:`$out` stage has the following syntax:
63
62
output database must already exist.
64
63
65
64
* - :ref:`coll <out-collection>`
66
-
67
65
- .. _out-collection:
68
66
69
67
The output collection name.
@@ -81,60 +79,60 @@ The :pipeline:`$out` stage has the following syntax:
81
79
collection. The input collection for a pipeline can be sharded.
82
80
To output to a sharded collection, see :pipeline:`$merge`
83
81
(Available starting in MongoDB 4.2).
84
-
85
82
- The :pipeline:`$out` operator cannot write results to a
86
83
:doc:`capped collection </core/capped-collections>`.
84
+ - If you modify a collection with an :atlas:`Atlas Search
85
+ </atlas-search>` index, you must first delete and then re-create
86
+ the search index. Consider using :pipeline:`$merge` instead.
87
+
87
88
88
89
.. _out-merge-comparison:
89
90
90
91
Comparison with ``$merge``
91
92
~~~~~~~~~~~~~~~~~~~~~~~~~~
92
93
93
- .. note:: ``$merge`` and ``$out`` Comparison
94
-
95
- With the introduction of :pipeline:`$merge` in version 4.2, MongoDB
96
- provides two stages, :pipeline:`$merge` and :pipeline:`$out`, for
97
- writing the results of the aggregation pipeline to a collection. The
98
- following summarizes the capabilities of the two stages:
99
-
100
- .. list-table::
101
- :header-rows: 1
102
- :class: border-table
103
-
104
- * - :pipeline:`$out`
105
- - :pipeline:`$merge`
106
- * - - Available starting in MongoDB 2.6
107
- - - Available starting in MongoDB 4.2
108
- * - - Can output to a collection in the same or, starting in
109
- MongoDB 4.4, different database.
110
- - - Can output to a collection in the same or different database.
111
- * - - Creates a new collection if the output collection does not
112
- already exist.
113
- - - Creates a new collection if the output collection does not
114
- already exist.
115
- * - - Replaces the output collection completely if it already exists.
116
- - - Can incorporate results (insert new documents, merge
117
- documents, replace documents, keep existing documents, fail
118
- the operation, process documents with a custom update pipeline) into
119
- an existing collection.
120
-
121
- Can replace the content of the collection but only if the
122
- aggregation results contain a match for all existing
123
- documents in the collection.
124
- * - - Cannot output to a sharded collection. Input collection,
125
- however, can be sharded.
126
- - - Can output to a sharded collection. Input collection can
127
- also be sharded.
128
- * - - Corresponds to SQL statements:
129
- - ``INSERT INTO T2 SELECT FROM T1``.
130
- - ``SELECT INTO T2 FROM T1``.
131
- - - Corresponds to SQL statements:
132
- - ``MERGE``.
133
- - ``INSERT INTO T2 SELECT FROM T1``.
134
- - ``SELECT INTO T2 FROM T1``.
135
- - Create/Refresh Materialized Views.
94
+ With the introduction of :pipeline:`$merge` in version 4.2, MongoDB
95
+ provides two stages, :pipeline:`$merge` and :pipeline:`$out`, for
96
+ writing the results of the aggregation pipeline to a collection. The
97
+ following summarizes the capabilities of the two stages:
136
98
99
+ .. list-table::
100
+ :header-rows: 1
137
101
102
+ * - :pipeline:`$out`
103
+ - :pipeline:`$merge`
104
+ * - - Available starting in MongoDB 2.6
105
+ - - Available starting in MongoDB 4.2
106
+ * - - Can output to a collection in the same or, starting in
107
+ MongoDB 4.4, different database.
108
+ - - Can output to a collection in the same or different database.
109
+ * - - Creates a new collection if the output collection does not
110
+ already exist.
111
+ - - Creates a new collection if the output collection does not
112
+ already exist.
113
+ * - - Replaces the output collection completely if it already exists.
114
+ - - Can incorporate results (insert new documents, merge
115
+ documents, replace documents, keep existing documents, fail
116
+ the operation, process documents with a custom update pipeline) into
117
+ an existing collection.
118
+
119
+ Can replace the content of the collection but only if the
120
+ aggregation results contain a match for all existing
121
+ documents in the collection.
122
+ * - - Cannot output to a sharded collection. Input collection,
123
+ however, can be sharded.
124
+ - - Can output to a sharded collection. Input collection can
125
+ also be sharded.
126
+ * - - Corresponds to SQL statements:
127
+
128
+ - ``INSERT INTO T2 SELECT FROM T1``
129
+ - ``SELECT INTO T2 FROM T1``
130
+ - - Corresponds to SQL statements:
131
+
132
+ - ``MERGE``
133
+ - ``INSERT INTO T2 SELECT FROM T1``
134
+ - ``SELECT INTO T2 FROM T1``
135
+ - Create/Refresh Materialized Views
138
136
139
137
Behaviors
140
138
---------
@@ -193,6 +191,10 @@ The pipeline will fail to complete if the documents produced by the
193
191
pipeline would violate any unique indexes, including the index on the
194
192
``_id`` field of the original output collection.
195
193
194
+ If the :pipeline:`$out` operation modifies a collection with an
195
+ :atlas:`Atlas Search </atlas-search>` index, you must delete and
196
+ re-create the search index. Consider using :pipeline:`$merge` instead.
197
+
196
198
``majority`` Read Concern
197
199
~~~~~~~~~~~~~~~~~~~~~~~~~
198
200
0 commit comments