我尝试在我的搜索中添加范围过滤器(仅显示工作流程状态< = 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"
}
答案 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')
)
)
)