Elasticsearch排除结果

时间:2015-11-03 13:56:20

标签: php elasticsearch elastica

您好我想排除内有两个值的结果

喜欢

if ($type == 'doc' && $statut == 'inactive') 
            return false;

所以我喜欢使用bool

$filter ['bool'] ['should'] ['bool'] ['must_not'][] = array (
        'term' => array (
                'type' => "doc"
        ),
        'term' => array (
                'statut' => "inactive"
        )
);

但这不起作用,你可以帮助我

编辑:明确我想排除结果有类型=='doc'和statut =='无效'

1 个答案:

答案 0 :(得分:1)

我找到了

$filter ['bool'] ['must_not'] []  = array(
    'bool' => array(
        'must' => array(
            array('term' => array('type' => "doc" )),
            array('term' => array('statut' => "inactive")),
            ) 
        ) 
    );