File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,20 @@ type: string
11
11
---
12
12
arg_name : field
13
13
description : |
14
- The index specification document to use as the shard key. The shard
15
- key determines how MongoDB distributes the documents among the shards.
14
+ The index specification document to use as the
15
+ :doc:`shard key </core/sharding-shard-key/>`. The shard key
16
+ determines how MongoDB distributes the documents among the shards.
17
+
18
+ The *key* of the index specification document is the field to use as
19
+ the shard key. The *value* of the document must be one of the
20
+ following:
21
+
22
+ - ``1`` to indicate forward traversal for the field.
23
+
24
+ - ``-1`` to indicate reverse traversal for the field.
25
+
26
+ - ``"hashed"`` to specify a
27
+ :ref:`hashed shard key <hashed-shard-keys>`.
16
28
17
29
Unless the collection is empty, the index must exist prior to the
18
30
:dbcommand:`shardCollection` command. If the collection is empty,
@@ -48,7 +60,7 @@ description: |
48
60
shard key <sharding-hashed-sharding>`. MongoDB will then create and
49
61
balance chunks across the cluster. The ``numInitialChunks`` must be
50
62
less than ``8192`` per shard.
51
-
63
+
52
64
.. versionchanged:: 3.4
53
65
54
66
If the collection is not empty or the shard key is not a hashed
Original file line number Diff line number Diff line change @@ -61,11 +61,14 @@ Choosing the best shard key to effectively distribute load among your
61
61
shards requires some planning. Review :ref:`sharding-shard-key`
62
62
regarding choosing a shard key and restrictions.
63
63
64
+ .. _hashed-shard-keys:
65
+
64
66
Hashed Shard Keys
65
67
~~~~~~~~~~~~~~~~~
66
68
67
69
:ref:`Hashed shard keys <sharding-hashed-sharding>` use a
68
- hashed index of a single field as the shard key.
70
+ :doc:`hashed index </core/index-hashed/#index-hashed-index>` of a
71
+ single field as the shard key.
69
72
70
73
Use the form ``{field: "hashed"}`` to specify a hashed shard key.
71
74
Hashed shard keys may not be compound indexes.
You can’t perform that action at this time.
0 commit comments