Skip to content

Improvements to map-reduce command reference #2079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions source/includes/parameters-map-reduce.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ members of replica sets.
Output to a Collection with an Action
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This option is only available when passing ``out`` a collection that
already exists. It is not available on secondary members of replica sets.
This option is only available when passing a collection that
already exists to ``out``. It is not available
on secondary members of replica sets.

.. code-block:: javascript

Expand Down Expand Up @@ -182,7 +183,7 @@ following parameters:

- ``db``:

Optional.The name of the database that you want the map-reduce
Optional. The name of the database that you want the map-reduce
operation to write its output. By default this will be the same
database as the input collection.

Expand All @@ -196,15 +197,16 @@ following parameters:

.. versionadded:: 2.2

Optional. Specify output operation as non-atomic and is valid *only*
for ``merge`` and ``reduce`` output modes which may take minutes to
Optional. Specify output operation as non-atomic. This applies **only**
to the ``merge`` and ``reduce`` output modes, which may take minutes to
execute.

If ``nonAtomic`` is ``true``, the post-processing step will prevent
MongoDB from locking the database; however, other clients will be
able to read intermediate states of the output collection. Otherwise
the map reduce operation must lock the database during
post-processing.
By default ``nonAtomic`` is ``false``, and the map-reduce
operation locks the database during post-processing.

If ``nonAtomic`` is ``true``, the post-processing step prevents
MongoDB from locking the database: during this time, other clients
will be able to read intermediate states of the output collection.

Output Inline
~~~~~~~~~~~~~~
Expand Down
28 changes: 14 additions & 14 deletions source/reference/command/mapReduce-field.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ description: |

See :ref:`mapReduce-reduce-cmd` for more information.
---
object:
name: mapReduce
type: command
field:
optional: true
type: field
name: finalize
type: Javascript function
position: 7
description: |
Follows the ``reduce`` method and modifies the output.

See :ref:`mapReduce-finalize-cmd` for more information.
---
object:
name: mapReduce
type: command
Expand Down Expand Up @@ -103,20 +117,6 @@ description: |
Specifies a maximum number of documents for the input into the
``map`` function.
---
object:
name: mapReduce
type: command
field:
optional: true
type: field
name: finalize
type: Javascript function
position: 7
description: |
Follows the ``reduce`` method and modifies the output.

See :ref:`mapReduce-finalize-cmd` for more information.
---
object:
name: mapReduce
type: command
Expand Down
13 changes: 7 additions & 6 deletions source/reference/command/mapReduce.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ mapReduce
mapReduce: <collection>,
map: <function>,
reduce: <function>,
finalize: <function>,
out: <output>,
query: <document>,
sort: <document>,
limit: <number>,
finalize: <function>,
scope: <document>,
jsMode: <boolean>,
verbose: <boolean>
Expand Down Expand Up @@ -75,17 +75,18 @@ mapReduce
:start-after: start-reduce
:end-before: end-reduce

.. _mapreduce-finalize-cmd:

.. include:: /includes/parameters-map-reduce.rst
:start-after: start-finalize
:end-before: end-finalize

.. _mapreduce-out-cmd:

.. include:: /includes/parameters-map-reduce.rst
:start-after: start-out
:end-before: end-out

.. _mapreduce-finalize-cmd:

.. include:: /includes/parameters-map-reduce.rst
:start-after: start-finalize
:end-before: end-finalize

Map-Reduce Examples
-------------------
Expand Down