@@ -37,7 +37,8 @@ The command has the following syntax:
3737 query: <query>,
3838 readConcern: <read concern document>,
3939 collation: <collation document>,
40- comment: <any>
40+ comment: <any>,
41+ hint: <string or document>
4142 }
4243 )
4344
@@ -86,7 +87,14 @@ The command takes the following fields:
8687 - .. include:: /includes/extracts/comment-content.rst
8788
8889 .. versionadded:: 4.4
89-
90+
91+ * - ``hint``
92+ - string or document
93+ - Optional. Specify the index name, either as a string or a document. If specified,
94+ the query planner only considers plans using the hinted index. For more details,
95+ see :ref:`Specify an Index <index-example>`.
96+
97+ .. versionadded:: 7.1
9098
9199.. include:: /includes/note-distinct-bson-limit-agg-alternative.rst
92100
@@ -363,3 +371,22 @@ majority of the nodes.
363371 )
364372
365373.. include:: /includes/usage-read-concern-majority.rst
374+
375+ .. _index-example:
376+
377+ Specify an Index
378+ ~~~~~~~~~~~~~~~~
379+
380+ You can specify an index name or pattern using the hint option.
381+
382+ To specify a hint based on an index name:
383+
384+ .. code-block:: javascript
385+
386+ db.runCommand ( { distinct: "inventory", key: "dept", hint: "sizes" } )
387+
388+ To specify a hint based on an index pattern:
389+
390+ .. code-block:: javascript
391+
392+ db.runCommand ( { distinct: "inventory", key: "dept", hint: { sizes: 1 } } )
0 commit comments