Skip to content

DOCS-10671 - Expand key description for shardCollection command #3216

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

Merged
merged 1 commit into from
Feb 1, 2018
Merged
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
18 changes: 15 additions & 3 deletions source/includes/apiargs-dbcommand-shardCollection-field.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ type: string
---
arg_name: field
description: |
The index specification document to use as the shard key. The shard
key determines how MongoDB distributes the documents among the shards.
The index specification document to use as the
:doc:`shard key </core/sharding-shard-key/>`. The shard key
determines how MongoDB distributes the documents among the shards.

The *key* of the index specification document is the field to use as
the shard key. The *value* of the document must be one of the
following:

- ``1`` to indicate forward traversal for the field.

- ``-1`` to indicate reverse traversal for the field.

- ``"hashed"`` to specify a
:ref:`hashed shard key <hashed-shard-keys>`.

Unless the collection is empty, the index must exist prior to the
:dbcommand:`shardCollection` command. If the collection is empty,
Expand Down Expand Up @@ -48,7 +60,7 @@ description: |
shard key <sharding-hashed-sharding>`. MongoDB will then create and
balance chunks across the cluster. The ``numInitialChunks`` must be
less than ``8192`` per shard.

.. versionchanged:: 3.4

If the collection is not empty or the shard key is not a hashed
Expand Down
5 changes: 4 additions & 1 deletion source/reference/command/shardCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ Choosing the best shard key to effectively distribute load among your
shards requires some planning. Review :ref:`sharding-shard-key`
regarding choosing a shard key and restrictions.

.. _hashed-shard-keys:

Hashed Shard Keys
~~~~~~~~~~~~~~~~~

:ref:`Hashed shard keys <sharding-hashed-sharding>` use a
hashed index of a single field as the shard key.
:doc:`hashed index </core/index-hashed/#index-hashed-index>` of a
single field as the shard key.

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