diff --git a/source/includes/fact-validate-metadata.rst b/source/includes/fact-validate-metadata.rst new file mode 100644 index 00000000000..63c9425934b --- /dev/null +++ b/source/includes/fact-validate-metadata.rst @@ -0,0 +1,33 @@ +*Optional*. A flag which allows users to perform a quick validation to +detect invalid index options without scanning all of the documents and +indexes. + +- If ``true``, a metadata validation scan is performed. + +- If ``false``, no metadata validation scan is not performed. + +The default is ``false``. + +Running the validate command with ``{ metadata: true }`` is not +supported with any other :dbcommand:`validate` options. + +The ``metadata`` validation option: + +- Provides you a faster way of identifying invalid indexes by scanning + only collections metadata. + +- Provides an alternative to dropping and recreating multiple invalid + indexes when used with the :doc:`collMod ` + command. + +The ``metadata`` validation option only scans collection metadata to +find invalid indexes more quickly. + +If there is an invalid index detected, the validate command will prompt +you to use the :dbcommand:`collMod` command to remove invalid indexes. + +.. code-block:: javascript + + db.runCommand( { collMod: } ) + +.. versionadded:: 5.0 \ No newline at end of file diff --git a/source/includes/fact-validate-repair-option.rst b/source/includes/fact-validate-repair-option.rst index 29d8cb0b5a7..e933da3b987 100644 --- a/source/includes/fact-validate-repair-option.rst +++ b/source/includes/fact-validate-repair-option.rst @@ -29,7 +29,8 @@ The repair fixes these issues: - If corrupt documents with invalid BSON data are found, the documents are removed. -.. seealso:: :option:`--repair ` option for - :binary:`~bin.mongod` +.. seealso:: + + :option:`--repair ` option for :binary:`~bin.mongod` .. versionadded:: 5.0 diff --git a/source/reference/command/validate.txt b/source/reference/command/validate.txt index 71c88115c86..360a051f2a2 100644 --- a/source/reference/command/validate.txt +++ b/source/reference/command/validate.txt @@ -44,7 +44,8 @@ The command has the following syntax: db.runCommand( { validate: , // Collection name full: , // Optional - repair: // Optional, added in MongoDB 5.0 + repair: , // Optional, added in MongoDB 5.0 + metadata: // Optional, added in MongoDB 5.0 } ) :binary:`~bin.mongosh` also provides a wrapper @@ -96,6 +97,12 @@ The command takes the following fields: .. include:: /includes/fact-validate-repair-option.rst + * - :ref:`metadata ` + - boolean + + - .. _cmd-validate-metadata: + + .. include:: /includes/fact-validate-metadata.rst Behavior -------- @@ -159,6 +166,13 @@ Examples db.runCommand( { validate: "myCollection", repair: true } ) +- To validate the metadata in the ``myCollection`` collection, + specify :ref:`meta data: true `: + + .. code-block:: javascript + + db.runCommand( { validate: "myCollection", metadata: true } ) + .. _validate-output: Validate Output diff --git a/source/release-notes/5.0.txt b/source/release-notes/5.0.txt index 199426e3c93..44fa2be729a 100644 --- a/source/release-notes/5.0.txt +++ b/source/release-notes/5.0.txt @@ -776,6 +776,14 @@ The :dbcommand:`validate` command and :method:`db.collection.validate()` helper method also return a new :data:`~validate.repaired` boolean value that is ``true`` if the collection was repaired. +Metadata Option Added for ``validate`` Command +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Starting in MongoDB 5.0, the :dbcommand:`validate` command and +the :method:`db.collection.validate()` helper method have a new +:ref:`metadata ` option that quickly validates +collections and detects invalid index options. + ``validate`` Command Reports Document Schema Violations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~