i'm have a collection with records like this
> db.company.findOne({companyId:1})
{
"_id" : ObjectId("4e22ff08eefdd839f60ab95f"),
"lastUpdate" : ISODate("2011-07-11T17:00:00Z"),
"errorCount" : 0,
"house" : 49,
"phones" : [
{
"cityCode" : "3852",
"number" : "461423",
"type" : "phone"
},
{
"cityCode" : "3852",
"number" : "461317",
"type" : "phone"
}
],
"houseAdd" : "",
"rubricsId" : [
NumberLong(184108177),
NumberLong(184108175)
],
"companyId" : NumberLong(1)
}
now i'm try to find all companies with phone number start with 8-800 i'm try to search my query
db.company.find({"phones.number":/8-800.*/}
and get an empty list. But
db.company.find({"phones.number":/8.*/})
return all companies which phone numbers starts with eight. AFAIK '-' isn't a special char for regex in this context? I'm try regex '8\-800' with same result. Where's i'm wrong?
8\-800.*)? Maybe the mongo regex engine doesn't like dashes even if they are outside[]/8.800.*/? Are you sure that you havephones.numbervalues that contain "8-800"?