@@ -257,15 +257,16 @@ sufficient split-ability.
257
257
Indexes
258
258
-------
259
259
260
- All sharded collections **must** have an index on the :term:`shard
261
- key`. If you shard a collection that does not yet contain documents
262
- and does *not* have this index specified , the
263
- :dbcommand:`shardCollection` will create an index on the shard key. If
264
- the collection already contains documents, you must create this index
265
- before using :dbcommand:`shardCollection`.
260
+ All sharded collections **must** have an index that starts with the
261
+ :term:`shard key`. If you shard a collection that does not yet contain
262
+ documents and *without* such an index, the :dbcommand:`shardCollection`
263
+ will create an index on the shard key. If the collection already
264
+ contains documents, you must create an appropriate index before using
265
+ :dbcommand:`shardCollection`.
266
266
267
267
.. versionchanged:: 2.2
268
- The index on the shard key can be an index of the shard key itself,
268
+ The index on the shard key no longer needs to be identical to the
269
+ shard key. This index can be an index of the shard key itself as before,
269
270
or a :ref:`compound index <sharding-index-type-compound>` where the
270
271
shard key is the prefix of the index. This index *cannot* be a
271
272
multikey index.
@@ -291,6 +292,13 @@ and you want to replace this with an index on the field ``{ zipcode:
291
292
292
293
The index on the shard key **cannot** be a multikey index.
293
294
295
+ As above, an index on ``{ zipcode: 1, username: 1 }`` can only
296
+ replace an index on ``zipcode`` if there are no array values for
297
+ the ``username`` field.
298
+
299
+ If you drop the last appropriate index for the shard key, recover
300
+ by recreating a index on just the shard key.
301
+
294
302
.. index:: balancing; internals
295
303
.. _sharding-balancing-internals:
296
304
0 commit comments