Elasticsearch 或并查询

$where = array();
//地理系列
$city_list = $request->city_list;
if (!empty($city_list)) {
    foreach ($city_list as $v) {
        $city_where[]['bool']['filter']['match_phrase']['city']['query'] = htmlspecialchars(strip_tags(trim($v)));
    }
}
$province_list = $request->province_list;
if (!empty($province_list)) {
    foreach ($province_list as $v) {
        $city_where[]['bool']['filter']['match_phrase']['province']['query'] = htmlspecialchars(strip_tags(trim($v)));
    }
}
$country_list = $request->country_list;
if (!empty($country_list)) {
    foreach ($country_list as $v) {
        $city_where[]['bool']['filter']['match_phrase']['country']['query'] = htmlspecialchars(strip_tags(trim($v)));
    }
}
if (!empty($city_where)) {
    $where[]['bool']['should'] = $city_where;
}
$ip_list = $request->ip_list;
if (!empty($ip_list)) {
    foreach ($ip_list as $v) {
        $ip_where[]['bool']['filter']['match_phrase']['ip']['query'] = trim($v);
    }
}
if (!empty($ip_where)) {
    $where[]['bool']['should'] = $ip_where;
}
$EsModel = new EsBaseHelper();
//总数据条数
$totalParams['index'] = getenv('ES_INDEX');
$totalParams['type'] = getenv('ES_TYPE');
$totalParams['from'] = 0;
$totalParams['size'] = 0;
$totalParams['body']['query']["constant_score"]["filter"]['bool']['must'] = $where;
$es_info = $EsModel->search($totalParams);
本作品采用《CC 协议》,转载必须注明作者和本文链接
Vckin
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!