mongodb/mongoid · error · Mongoid::Errors::InvalidElemMatchOperator
Invalid $elemMatch operator '%{operator}'.
Error message
Invalid $elemMatch operator '%{operator}'. What it means
Error "Invalid $elemMatch operator '%{operator}'." thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/matcher/elem_match_expression.rb:24
# also have a regular expression predicate.
#
# @api private
module ElemMatchExpression
# Returns whether a document satisfies an $elemMatch expression.
#
# @param [ Mongoid::Document ] document The document.
# @param [ Hash ] expr The $elemMatch condition predicate.
#
# @return [ true | false ] Whether the document matches.
#
# @api private
module_function def matches?(document, expr)
Expression.matches?(document, expr)
rescue Mongoid::Errors::InvalidExpressionOperator
begin
FieldExpression.matches?(true, document, expr)
rescue Mongoid::Errors::InvalidFieldOperator => exc
raise Mongoid::Errors::InvalidElemMatchOperator.new(exc.operator)
end
end
end
end
end
View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/matcher/elem_match_expression.rb:24 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23).
Data as JSON: /api/errors/b6d8151e9a6c8fc2.
Report an issue: GitHub.