# MongoServerError: query pattern not covered by any index

- **ID:** `mongodb/query-pattern-not-covered-by-index`
- **Domain:** mongodb
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A query's filter or sort pattern does not match any existing index, forcing a collection scan.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| mongodb-5.0 | active | — | — |
| mongodb-6.0 | active | — | — |
| mongodb-7.0 | active | — | — |

## Workarounds

1. **Create a compound index that matches the query filter and sort fields in the correct order.** (90% success)
   ```
   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.** (95% success)
   ```
   Use explain() to analyze the query and determine the optimal index.
   ```

## Dead Ends

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