# 查询修饰符

除了MongoDB查询运算符外，还有许多`meta`运算符可让您修改查询的输出或行为。

> **注意**
>
> `mongo`从v3.2开始在Shell中不推荐使用
>
> 从v3.2开始，`mongo`shell 中不建议使用查询`meta`运算符。在`mongo`shell程序中，改用游标方法 。

驱动程序接口可以提供包装这些选项的游标方法。如果可能，请使用这些方法。否则，您可以使用以下两种语法之一添加这些选项：

```
db.collection.find( { <query> } )._addSpecial( <option> )
db.collection.find( { $query: { <query> }, <option> } )
```

## 运算符

### 修饰符

> **注意**
>
> `mongo`从v3.2开始在Shell中不推荐使用
>
> 从v3.2开始，`mongo`shell 中不建议使用查询`meta`运算符。在`mongo`shell程序中，改用游标方法 。

| 名称                                                                              | 描述                                           |
| ------------------------------------------------------------------------------- | -------------------------------------------- |
| [`$comment`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)     | 向查询添加注释，以标识数据库探查器输出中的查询。                     |
| [`$explain`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)     | 强制MongoDB报告查询执行计划。请参阅`explain()`。            |
| [`$hint`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)        | 仅强制MongoDB使用特定索引。请看`hint()`                  |
| [`$max`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)         | 指定要在查询中使用的索引的\_排他\_上限。请参阅`max()`。            |
| [`$maxTimeMS`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)   | 指定对游标进行处理操作的累积时间限制（以毫秒为单位）。请参阅`maxTimeMS()`。 |
| [`$min`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)         | 指定一个\_包容性的\_下限为索引在查询中使用。请参阅`min()`。          |
| [`$orderby`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)     | 返回带有根据排序规范排序的文档的游标。请参阅`sort()`。              |
| [`$query`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)       | 包装查询文档。                                      |
| [`$returnKey`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers)   | 强制游标仅返回索引中包含的字段。                             |
| [`$showDiskLoc`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers) | 修改返回的文档以包括对每个文档在磁盘上位置的引用。                    |

### 排序顺序

| 名称                                                                          | 描述                           |
| --------------------------------------------------------------------------- | ---------------------------- |
| [`$natural`](https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers) | 一种特殊的排序顺序，使用磁盘上的文档顺序对文档进行排序。 |

译者：李冠飞

校对：


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mongoing.com/can-kao/yun-suan-fu/query-modifiers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
