-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
sh.moveChunk.txt
79 lines (46 loc) · 1.74 KB
/
sh.moveChunk.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
==============
sh.moveChunk()
==============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: sh.moveChunk(namespace, query, destination)
Moves the :term:`chunk` that contains the document specified by the
``query`` to the ``destination`` shard. :method:`sh.moveChunk()`
provides a wrapper around the :dbcommand:`moveChunk` database
command and takes the following arguments:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Parameter
- Type
- Description
* - ``namespace``
- string
- The :term:`namespace` of the sharded collection that contains the
chunk to migrate.
* - ``query``
- document
- An equality match on the shard key that selects the chunk to move.
* - ``destination``
- string
- The name of the shard to move.
.. important:: In most circumstances, allow the :term:`balancer` to
automatically migrate :term:`chunks <chunk>`, and avoid calling
:method:`sh.moveChunk()` directly.
.. seealso:: :dbcommand:`moveChunk`, :method:`sh.splitAt()`,
:method:`sh.splitFind()`, :doc:`/sharding`, and :ref:`chunk
migration <sharding-chunk-migration>`.
Example
-------
Given the ``people`` collection in the ``records`` database, the
following operation finds the chunk that contains the documents with the
``zipcode`` field set to ``53187`` and then moves that chunk to the
shard named ``shard0019``:
.. code-block:: javascript
sh.moveChunk("records.people", { zipcode: "53187" }, "shard0019")