Error
Error Code:
170
MongoDB Error 170: Excessive Document Matches
Description
This error indicates that a MongoDB operation, configured to affect a single document or expecting a unique match, instead found multiple documents satisfying its query criteria. It commonly arises when an update, delete, or find-and-modify operation targets a document using a non-unique field or a broad query that matches more entries than intended.
Error Message
Too Many Matching Documents
Known Causes
3 known causesNon-Unique Query Field
An operation targeting a single document used a query field that resolved to multiple documents in the collection, violating the single-match expectation.
Missing Unique Index Enforcement
Data integrity issues arise when unique constraints are expected but not enforced by a unique index, allowing multiple documents with identical values to exist.
Flawed Query Logic
The query predicate for a single-document operation was too broad or incorrectly constructed, causing it to match multiple documents unexpectedly.
Solutions
Coming SoonGeneral Troubleshooting Tips
- Check the error message carefully for specific details
- Review recent changes that might have caused the error
- Search for the exact error code in the official documentation
- Check log files for additional context
- Try restarting the application or service