14 — TypeMismatch
queryconfiguration
A value has the wrong BSON type for the operation
What is happening?
TypeMismatch is returned when an operation encounters a value whose BSON type does not match what the operation expects. This can happen in query predicates, update operators, index key generation, or command arguments. For example, applying $inc to a string field, or using $regex on a numeric field.
Common causes
- Applying an arithmetic update operator ($inc, $mul) to a non-numeric field
- Query predicate type incompatible with the operator (e.g. $regex on a number)
- Schema changed and old documents contain a different type for the same field
- Aggregation expression receives an unexpected type from upstream stages
- Index build fails because a document field has a type the index does not support