@@ -20,32 +20,30 @@ Definition
20
20
The :method:`sh.reshardCollection()` method changes the shard key for
21
21
a collection and changes the distribution of your data.
22
22
23
+ Before you reshard a collection, read the the :ref:`reshard
24
+ requirements <reshard-requirements>` and :ref:`reshard limitations
25
+ <resharding-limitations>`.
26
+
23
27
.. |dbcommand| replace:: :dbcommand:`reshardCollection` command
24
28
.. include:: /includes/fact-mongosh-shell-method-alt.rst
25
29
26
- :method:` sh.reshardCollection()` takes the following arguments :
30
+ `` sh.reshardCollection()`` takes the following fields :
27
31
28
32
.. list-table::
29
33
:header-rows: 1
30
34
:widths: 20 20 80
31
35
32
- * - Parameter
33
-
36
+ * - Field
34
37
- Type
35
-
36
38
- Description
37
39
38
40
* - ``namespace``
39
-
40
41
- string
41
-
42
42
- The :term:`namespace` of the collection to shard in the form
43
43
``"<database>.<collection>"``.
44
44
45
45
* - ``key``
46
-
47
46
- document
48
-
49
47
- The document that specifies the new field or fields to use as the
50
48
:ref:`shard key <sharding-shard-key>`.
51
49
@@ -54,44 +52,34 @@ Definition
54
52
Set the field values to either:
55
53
56
54
- ``1`` for :doc:`ranged based sharding </core/ranged-sharding>`
57
-
58
55
- ``"hashed"`` to specify a
59
56
:ref:`hashed shard key <hashed-shard-keys>`.
60
57
61
58
See also :ref:`sharding-shard-key-indexes`
62
59
63
60
* - ``unique``
64
-
65
61
- boolean
66
-
67
62
- Optional. Specify whether there is a :doc:`uniqueness
68
63
</core/index-unique>` constraint on the shard key. Only
69
64
``false`` is supported. Defaults to ``false``.
70
65
71
66
* - ``options``
72
-
73
67
- document
74
-
75
68
- Optional. A document containing optional fields, including
76
69
``numInitialChunks``, ``collation`` and ``zones``.
77
70
78
-
79
- The ``options`` argument supports the following options:
71
+ The ``options`` field supports the following fields:
80
72
81
73
.. list-table::
82
74
:header-rows: 1
83
75
:widths: 20 20 80
84
76
85
- * - Parameter
86
-
77
+ * - Field
87
78
- Type
88
-
89
79
- Description
90
80
91
81
* - ``numInitialChunks``
92
-
93
82
- integer
94
-
95
83
- Optional. Specifies the initial number of chunks to create
96
84
across all shards in the cluster when resharding a collection.
97
85
The default is the number of chunks that exist for the
@@ -100,22 +88,19 @@ The ``options`` argument supports the following options:
100
88
``numInitialChunks`` must result in less than ``8192`` per shard.
101
89
102
90
* - ``collation``
103
-
104
91
- document
105
-
106
92
- Optional. If the collection specified to ``reshardCollection``
107
93
has a default :ref:`collation <collation>`, you *must* include a
108
94
collation document with ``{ locale : "simple" }``, or the
109
95
``reshardCollection`` command fails.
110
96
111
97
* - ``zones``
112
-
113
98
- array
114
-
115
99
- Optional. To maintain or add :ref:`zones <zone-sharding>`,
116
100
specify the zones for your collection in an array:
117
101
118
102
.. code-block:: javascript
103
+ :copyable: false
119
104
120
105
[
121
106
{
@@ -168,7 +153,7 @@ During the clone, apply, and catch-up phase:
168
153
169
154
.. note::
170
155
171
- If desired , you can manually force the resharding operation to
156
+ If required , you can manually force the resharding operation to
172
157
complete by issuing the :method:`sh.commitReshardCollection()`
173
158
method. This is useful if the current time estimate to complete the
174
159
resharding operation is an acceptable duration for your collection
@@ -182,8 +167,8 @@ During the clone, apply, and catch-up phase:
182
167
Commit Phase
183
168
~~~~~~~~~~~~
184
169
185
- - Once the resharding process reaches the commit phase, it may no longer
186
- be aborted with :method:`sh.abortReshardCollection()`.
170
+ - After the resharding process reaches the commit phase, the process
171
+ cannot be ended with :method:`sh.abortReshardCollection()`.
187
172
- When all shards have reached strict consistency, the resharding
188
173
coordinator commits the resharding operation and installs the new
189
174
routing table.
@@ -207,11 +192,12 @@ new shard key ``{ order_id: 1 }``:
207
192
208
193
.. code-block:: javascript
209
194
210
- sh.reshardCollection("sales.orders", { order_id: 1 })
195
+ sh.reshardCollection( "sales.orders", { order_id: 1 } )
211
196
212
- MongoDB returns the following :
197
+ Example output :
213
198
214
199
.. code-block:: javascript
200
+ :copyable: false
215
201
216
202
{
217
203
ok: 1,
0 commit comments