@@ -50,7 +50,6 @@ The :pipeline:`$out` stage has the following syntax:
5050 - Description
5151
5252 * - :ref:`db <out-db>`
53-
5453 - .. _out-db:
5554
5655 The output database name.
@@ -63,7 +62,6 @@ The :pipeline:`$out` stage has the following syntax:
6362 output database must already exist.
6463
6564 * - :ref:`coll <out-collection>`
66-
6765 - .. _out-collection:
6866
6967 The output collection name.
@@ -81,60 +79,60 @@ The :pipeline:`$out` stage has the following syntax:
8179 collection. The input collection for a pipeline can be sharded.
8280 To output to a sharded collection, see :pipeline:`$merge`
8381 (Available starting in MongoDB 4.2).
84-
8582 - The :pipeline:`$out` operator cannot write results to a
8683 :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+
8788
8889.. _out-merge-comparison:
8990
9091Comparison with ``$merge``
9192~~~~~~~~~~~~~~~~~~~~~~~~~~
9293
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:
13698
99+ .. list-table::
100+ :header-rows: 1
137101
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
138136
139137Behaviors
140138---------
@@ -193,6 +191,10 @@ The pipeline will fail to complete if the documents produced by the
193191pipeline would violate any unique indexes, including the index on the
194192``_id`` field of the original output collection.
195193
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+
196198``majority`` Read Concern
197199~~~~~~~~~~~~~~~~~~~~~~~~~
198200
0 commit comments