0

How to do NOT LIKE in mongoDB?

$paddress = new MongoRegex("/kendriya/");
$caddress = new MongoRegex("/India/");

 Array 
 (
 [$and] => Array
 (
    [0] => Array
        (
            [permanent_address] => Array
                (
                    [$not] => $paddress
                )

        )
    [1] => Array
        (
            [current_address] => Array
                (
                    [$not] => $caddress
                )

        )
        )
        )

I want implement $nin with regex to full text search but $nin and $regex not worked together.

Update: this is not a duplicate question. When I pass above array then result not getting because it is encode into json then it is convert into as

$and : 
[
{ permanent_address: { $not: "/kendriya/" } } ,
{ current_address: { $not:  "/India/" } } 
]
}
]

result not getting from above json array but actual mongodb syntax is

$and : 
[
{ permanent_address: { $not: /kendriya/ } } ,
{ current_address: { $not:  /India/ } } 
]
}
]

so how can I solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • $paddress = "/kendriya/"; $caddress ="/India/"; Array ( [$and] => Array ( [0] => Array ( [permanent_address] => Array ( [$not] => $paddress ) ) [1] => Array ( [current_address] => Array ( [$not] => $caddress ) ) ) ) – user3235105 Oct 17 '16 at 08:53
  • when i use above code and pass this array to find function then it doesn't return any records...i think its encode the array then backslash added to string value with double quoates thats why mongo doesn't return any records – user3235105 Oct 17 '16 at 08:57

0 Answers0