# MongoServerError: 查询模式未被任何索引覆盖

- **ID:** `mongodb/query-pattern-not-covered-by-index`
- **领域:** mongodb
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

查询的过滤或排序模式与任何现有索引不匹配，导致全集合扫描。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| mongodb-5.0 | active | — | — |
| mongodb-6.0 | active | — | — |
| mongodb-7.0 | active | — | — |

## 解决方案

1. ```
   Create a compound index that matches the query filter and sort fields in the correct order.
   ```
2. ```
   Use explain() to analyze the query and determine the optimal index.
   ```

## 无效尝试

- **** — Creating an index on a different field does not help; the index must match the query pattern. (90% 失败率)
- **** — Using hint() to force an unrelated index still results in a scan. (85% 失败率)
