Elasticsearch范围过滤器无法正常工作(未注册过滤器)

时间:2015-06-26 15:08:15

标签: php elasticsearch

我尝试在我的搜索中添加范围过滤器(仅显示工作流程状态< = 5的文章)并出现错误
我的射程有什么问题?

    $searchParams = array(
        'index' => $config->search->index,
        'type' => 'xxxxxxxxxx',
        'size' => 10,
        'from' => ($page - 1) * 10,
        'body' => array(
            'query' => array(
                'filtered' => array(
                    'query' => array(
                        'multi_match' => array(
                            'query' => $query,
                            'fields' => array('title^8', 'caption^5', 'teasertext^4', 'articletext^2') // ^x = Gewichtung des Felds
                        ),
                    ),
                    'filter' => array(
                        'bool' => array(
                            'must' => array(
                                'term' => array(
                                    'deleted' => 0,
                                    'visible' => 1
                                ),
                                'range' => array(
                                    'workflow_status' => array('lte' => '5')
                                )
                            )
                        )
                    )
                )
            )
        ),
        'sort' => array('_score', '_id:desc')

这里我的状态映射:

"workflow_status": {
                    "type":  "integer",
                    "index": "not_analyzed"
                }

1 个答案:

答案 0 :(得分:1)

您所拥有的不是有效的查询DSL,必须采用数组。 身体应该是这些方面的东西:

body =>
    array(
        'query' => array(
        'filtered' => array(
            'query' => array(
                'multi_match' => array(
                    'query' => $query,
                    'fields' => array('title^8', 'caption^5', 'teasertext^4', 'articletext^2') // ^x = Gewichtung des Felds
                ),
            ),
            'filter' => array(
                'bool' => array(
                    'must' => array(
                        array(
                            'term' => array(
                                'deleted' => 0
                            )
                        ),
                        array('term' => array(
                            'visible' => 1
                            )
                        ),
                        array(
                            'range' => array(
                                'workflow_status' => array('lte' => '5')
                            )
                        )
                    )