php和mongodb通过名称和文本legnth查找文档


php and mongo db find doc by name and text legnth

hi我需要php和mongodb方面的帮助。我的服务器中有这样的文档:

comment: "aaaaaa"
id: "11111"
_id: {$id: "564c5a297efcf0181d00002c"}
active: true
flag: 7

我需要对它进行身份识别测试

$ids = "5555,3333,2222,11111"

我需要在我的文档中搜索所有带有此id的结果我是这样做的:

$query = array("id" => array('$in'=> $where));

它工作正常,但现在我需要添加另一个条件。

我需要在我的文档中找到所有的ID,但也有的ID

"active" => true,
"comment.length" > 2

因此rusult查询将为我提供所有具有其中一个id&active=true&注释长度>2我设法找到了一个活动和评论长度的解决方案:

    $jsCond = "function() {
    return this.comment.length > 2 && this.active == true ;
    }";

但不知道如何让它发挥好作用。

我需要帮助!!谢谢

我已经解决了它:

$jsCond = "function() {  return this.comment.length > 2 && this.active == true ; }";
$query2 = array( '$and' => array(
    array("id" => array('$in'=> $where)),
    array('$where' => $jsCond )
));