Skip to content

Commit 5501443

Browse files
jeff-allen-mongokay-kim
authored andcommitted
DOCS-10671 - Expand key description for shardCollection command
1 parent b286c10 commit 5501443

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

source/includes/apiargs-dbcommand-shardCollection-field.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@ type: string
1111
---
1212
arg_name: field
1313
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>`.
1628
1729
Unless the collection is empty, the index must exist prior to the
1830
:dbcommand:`shardCollection` command. If the collection is empty,
@@ -48,7 +60,7 @@ description: |
4860
shard key <sharding-hashed-sharding>`. MongoDB will then create and
4961
balance chunks across the cluster. The ``numInitialChunks`` must be
5062
less than ``8192`` per shard.
51-
63+
5264
.. versionchanged:: 3.4
5365
5466
If the collection is not empty or the shard key is not a hashed

source/reference/command/shardCollection.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ Choosing the best shard key to effectively distribute load among your
6161
shards requires some planning. Review :ref:`sharding-shard-key`
6262
regarding choosing a shard key and restrictions.
6363

64+
.. _hashed-shard-keys:
65+
6466
Hashed Shard Keys
6567
~~~~~~~~~~~~~~~~~
6668

6769
: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.
6972

7073
Use the form ``{field: "hashed"}`` to specify a hashed shard key.
7174
Hashed shard keys may not be compound indexes.

0 commit comments

Comments
 (0)