Skip to content

Commit c649b9f

Browse files
ianf-mongodbjeff-allen-mongo
authored andcommitted
DOCS-14822 Adding metadata flag context to validate()
1 parent edbf308 commit c649b9f

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.4

source/includes/fact-validate-repair-option.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ The repair fixes these issues:
2929
- If corrupt documents with invalid BSON data are found, the documents
3030
are removed.
3131

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`
3435

3536
.. versionadded:: 5.0

source/reference/command/validate.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ The command has the following syntax:
4444
db.runCommand( {
4545
validate: <string>, // Collection name
4646
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.4
4849
} )
4950

5051
:binary:`~bin.mongosh` also provides a wrapper
@@ -96,6 +97,12 @@ The command takes the following fields:
9697

9798
.. include:: /includes/fact-validate-repair-option.rst
9899

100+
* - :ref:`metadata <cmd-validate-metadata>`
101+
- boolean
102+
103+
- .. _cmd-validate-metadata:
104+
105+
.. include:: /includes/fact-validate-metadata.rst
99106

100107
Behavior
101108
--------
@@ -159,6 +166,13 @@ Examples
159166

160167
db.runCommand( { validate: "myCollection", repair: true } )
161168

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+
162176
.. _validate-output:
163177

164178
Validate Output

0 commit comments

Comments
 (0)