1、 对查询内容过滤
// 索引范围
$params['index'] = $index;
// 时间范围
if (!empty($timeRange)) {
$params['query']['bool']['filter']['range']['logTime'] = array(
'gte' => $timeRange['startTime'],
'lte' => $timeRange['endTime']
);
}
2、条件筛选:
// 筛选条件
if (!empty($condition)) {
foreach ($condition as $key => $value) {
$params['query']['bool']['must'][]['match_phrase'] = array(
$key => $value
);
}
}
3、对结果筛选
// 结果筛选
if (!empty($mustExist)) {
foreach ($mustExist as $value) {
$params['query']['bool']['must'][]['exists'] = array(
'field' => $value
);
}
}