File tree Expand file tree Collapse file tree 4 files changed +59
-3
lines changed Expand file tree Collapse file tree 4 files changed +59
-3
lines changed Original file line number Diff line number Diff line change
1
+ *Optional *. A flag which allows users to perform a quick validation to
2
+ detect invalid index options without scanning all of the documents and
3
+ indexes.
4
+
5
+ - If ``true ``, a metadata validation scan is performed.
6
+
7
+ - If ``false ``, no metadata validation scan is not performed.
8
+
9
+ The default is ``false ``.
10
+
11
+ Running the validate command with ``{ metadata: true } `` is not
12
+ supported with any other :dbcommand: `validate ` options.
13
+
14
+ The ``metadata `` validation option:
15
+
16
+ - Provides you a faster way of identifying invalid indexes by scanning
17
+ only collections metadata.
18
+
19
+ - Provides an alternative to dropping and recreating multiple invalid
20
+ indexes when used with the :doc: `collMod </reference/command/collMod >`
21
+ command.
22
+
23
+ The ``metadata `` validation option only scans collection metadata to
24
+ find invalid indexes more quickly.
25
+
26
+ If there is an invalid index detected, the validate command will prompt
27
+ you to use the :dbcommand: `collMod ` command to remove invalid indexes.
28
+
29
+ .. code-block :: javascript
30
+
31
+ db .runCommand ( { collMod: < collectionName> } )
32
+
33
+ .. versionadded :: 5.0
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ The repair fixes these issues:
29
29
- If corrupt documents with invalid BSON data are found, the documents
30
30
are removed.
31
31
32
- .. seealso :: :option:`--repair <mongod --repair>` option for
33
- :binary: `~bin.mongod `
32
+ .. seealso ::
33
+
34
+ :option: `--repair <mongod --repair> ` option for :binary: `~bin.mongod `
34
35
35
36
.. versionadded :: 5.0
Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ The command has the following syntax:
44
44
db.runCommand( {
45
45
validate: <string>, // Collection name
46
46
full: <boolean>, // Optional
47
- repair: <boolean> // Optional, added in MongoDB 5.0
47
+ repair: <boolean>, // Optional, added in MongoDB 5.0
48
+ metadata: <boolean> // Optional, added in MongoDB 5.0
48
49
} )
49
50
50
51
:binary:`~bin.mongosh` also provides a wrapper
@@ -96,6 +97,12 @@ The command takes the following fields:
96
97
97
98
.. include:: /includes/fact-validate-repair-option.rst
98
99
100
+ * - :ref:`metadata <cmd-validate-metadata>`
101
+ - boolean
102
+
103
+ - .. _cmd-validate-metadata:
104
+
105
+ .. include:: /includes/fact-validate-metadata.rst
99
106
100
107
Behavior
101
108
--------
@@ -159,6 +166,13 @@ Examples
159
166
160
167
db.runCommand( { validate: "myCollection", repair: true } )
161
168
169
+ - To validate the metadata in the ``myCollection`` collection,
170
+ specify :ref:`meta data: true <cmd-validate-metadata>`:
171
+
172
+ .. code-block:: javascript
173
+
174
+ db.runCommand( { validate: "myCollection", metadata: true } )
175
+
162
176
.. _validate-output:
163
177
164
178
Validate Output
Original file line number Diff line number Diff line change @@ -776,6 +776,14 @@ The :dbcommand:`validate` command and :method:`db.collection.validate()`
776
776
helper method also return a new :data:`~validate.repaired` boolean value
777
777
that is ``true`` if the collection was repaired.
778
778
779
+ Metadata Option Added for ``validate`` Command
780
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
781
+
782
+ Starting in MongoDB 5.0, the :dbcommand:`validate` command and
783
+ the :method:`db.collection.validate()` helper method have a new
784
+ :ref:`metadata <cmd-validate-metadata>` option that quickly validates
785
+ collections and detects invalid index options.
786
+
779
787
``validate`` Command Reports Document Schema Violations
780
788
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
781
789
You can’t perform that action at this time.
0 commit comments