Skip to content

Commit b80ba2b

Browse files
committed
DOCS-14821 Adding metadata flag context to validate()
1 parent 10cc97b commit b80ba2b

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed
Lines changed: 33 additions & 0 deletions
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

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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 15 additions & 1 deletion
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
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

source/release-notes/5.0.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,14 @@ The :dbcommand:`validate` command and :method:`db.collection.validate()`
776776
helper method also return a new :data:`~validate.repaired` boolean value
777777
that is ``true`` if the collection was repaired.
778778

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+
779787
``validate`` Command Reports Document Schema Violations
780788
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
781789

0 commit comments

Comments
 (0)