如何在mongoDB中不喜欢? $ regex和$ nin不能一起使用?

时间:2016-10-17 08:47:09

标签: php json mongodb

如何在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
                )

        )
        )
        )

我希望使用regex实现$nin到全文搜索,但$nin$regex无法一起使用。

更新:这不是一个重复的问题。当我传递上面的数组然后结果没有得到因为它被编码为json然后它被转换为

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

结果不是从json数组上面得到的,但实际的mongodb语法是

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

所以我该如何解决这个问题?

0 个答案:

没有答案