If a field type is specified as String, a BSON::Regexp::Raw query criteria will be converted to a String, instead of to a regex.
For example:
class Band include Mongoid::Document field :_id, type: String end > Band.where(_id: Regexp::Raw.new('^5:1480505452050829690_2035751180-')).limit(-1) => #<Mongoid::Criteria selector: {"_id"=>"#<BSON::Regexp::Raw:0x007f92e8bc70c8>"} options: {:limit=>-1} class: Band embedded: false>
It should be:
Band.where(_id: Regexp::Raw.new('^5:1480505452050829690_2035751180-')).limit(-1) => #<Mongoid::Criteria selector: {"_id"=>#<BSON::Regexp::Raw:0x007fc6441678c8 @pattern="^5:1480505452050829690_2035751180-", @options="">} options: {:limit=>-1} class: Band embedded: false>