Skip to content

Commit c6eecab

Browse files
authored
adds fact-drop-indexes-5.0.rst to backport this to v5.0 (#3219)
1 parent 25387cf commit c6eecab

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Starting in MongoDB 5.0, |drop-index| raises an error if you attempt
2+
to use it to remove the last remaining shard key compatible index.
3+
Passing ``"*"`` to |drop-index| drops all indexes except
4+
the ``_id`` index and the last remaining shard key compatible index,
5+
if one exists.

source/reference/command/dropIndexes.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ dropIndexes
1212

1313
.. dbcommand:: dropIndexes
1414

15+
.. versionchanged:: 5.0
16+
1517
The :dbcommand:`dropIndexes` command drops one or more indexes
16-
(except the index on the ``_id`` field) from the specified
17-
collection.
18-
19-
.. |method| replace:: :method:`db.collection.dropIndex()` and
20-
:method:`db.collection.dropIndexes()` helper methods.
21-
.. include:: /includes/fact-dbcommand-tip
18+
(except the index on the ``_id`` field and the last remaining shard
19+
key index, if one exists) from the specified collection.
2220

2321
The command has the following form:
2422

@@ -46,15 +44,17 @@ dropIndexes
4644

4745
- The index or indexes to drop.
4846

49-
- To drop all but the _id index from the collection,
50-
specify ``"*"``.
47+
- To drop all indexes except the ``_id`` index and the last
48+
remaining shard key index from the collection if one
49+
exists, specify ``"*"``.
5150

5251
- To drop a single index, specify either the index name,
5352
the index specification document (unless the index is a
5453
:doc:`text </core/index-text>` index), or an array of the
5554
index name. To drop a :doc:`text </core/index-text>` index,
5655
specify the index names instead of the index specification
57-
document.
56+
document. If this index is the last remaining shard key
57+
index, ``dropIndexes`` raises an error.
5858

5959
- To drop multiple indexes (Available starting in MongoDB
6060
4.2), specify an array of the index names.
@@ -77,6 +77,10 @@ dropIndexes
7777
Behavior
7878
--------
7979

80+
.. |drop-index| replace:: :dbcommand:`dropIndexes`
81+
82+
.. include:: /includes/fact-drop-indexes-5.0.rst
83+
8084
Kill related queries only
8185
~~~~~~~~~~~~~~~~~~~~~~~~~
8286

source/reference/method/db.collection.dropIndexes.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Definition
2222

2323

2424
Drops the specified index or indexes (except the index on the
25-
``_id`` field) from a collection.
25+
``_id`` field and the last remaining shard key index) from a
26+
collection.
2627

2728
You can use the method to:
2829

@@ -110,7 +111,9 @@ Behavior
110111
Cannot Drop ``Ready`` Indexes During In-Progress Index Builds
111112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112113

113-
.. include:: /includes/fact-5.0-dropindexes-inprog.rst
114+
.. |drop-index| replace:: :dbcommand:`dropIndexes`
115+
116+
.. include:: /includes/fact-drop-indexes-5.0.rst
114117

115118
Kill related queries only
116119
~~~~~~~~~~~~~~~~~~~~~~~~~

source/release-notes/5.0-compatibility.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,13 @@ Starting in MongoDB 5.0:
474474
creation. The ``wildcardProjection`` document that defines the index
475475
may contain :ref:`normalized syntax <normalized_wildcard_indexes>`
476476
that differs from the original index creation statements.
477-
477+
478+
- Passing ``"*"`` to :dbcommand:`dropIndexes` or
479+
:method:`db.collection.dropIndexes()` drops all indexes **except**
480+
for the ``_id`` index and the last remaining shard key index, if one
481+
exists. Attempts to explicitly drop the last remaining shard key index
482+
raise an error.
483+
478484
Starting in MongoDB 5.0.4 (and 4.4.10), the :query:`$mod`
479485
operator returns an error if the ``divisor`` or ``remainder`` values
480486
evaluate to certain values. See :ref:`$mod behavior <mod-behavior>`.

0 commit comments

Comments
 (0)