This is my mongodb find query:
db.getCollection('candidate').find({
"$or": [
{
"email_id": {
"$regex": {
"regex": "^ranjit",
"flags": "i"
}
}
},
{
"mobile_no": {
"$regex": {
"regex": "^ranjit",
"flags": "i"
}
}
},
{
"phone_no": {
"$regex": {
"regex": "^ranjit",
"flags": "i"
}
}
},
{
"skill_name": {
"$regex": {
"regex": "^ranjit",
"flags": "i"
}
}
},
{
"current_address": {
"$regex": {
"regex": "^ranjit",
"flags": "i"
}
}
},
{
"first_name": {
"$regex": {
"regex": "^ranjit",
"flags": "i"
}
}
}
]
}
)
Above mongo db query return me wrong tuples. It returns tuples who doesn't contain "ranjit", but actually I want tuples who contain "ranjit".
Could you explain why it's returning wrong tuples and what is the correct query?