封装Es商品搜索

main
ztt 8 months ago
parent 7e1b996c21
commit 2a4c2169e1
  1. 2
      app/api/controller/GoodsNew.php
  2. 24
      app/common/library/elasticsearch/Client.php

@ -27,7 +27,7 @@ class GoodsNew extends Controller
$goodsService = new GoodsEs(); $goodsService = new GoodsEs();
$list = $goodsService->list($params, $page, $limit); $list = $goodsService->list($params, $page, $limit);
$data['list'] = $list; $data['list'] = $list;
$data['total'] = $goodsService->count(); $data['total'] = $goodsService->count($params);
return $this->renderSuccess($data); return $this->renderSuccess($data);
} }

@ -233,8 +233,8 @@ class Client
];*/ ];*/
$must[] = [ $must[] = [
// 'match' => [$filed => $value] 'match' => [$filed => $value]
'match_phrase' => [$filed => $value] // 'match_phrase' => [$filed => $value]
]; ];
} }
} }
@ -281,7 +281,7 @@ class Client
public function query($isTotal = false) public function query($isTotal = false)
{ {
// try { try {
$this->parseQueryParams(); $this->parseQueryParams();
// dd($this->queryParams); // dd($this->queryParams);
@ -333,15 +333,15 @@ class Client
} }
// } catch (\Exception $e) { } catch (\Exception $e) {
//
// $msg = $e->getMessage(); $msg = $e->getMessage();
//
// $msg = '服务器开小差了~'; $msg = '服务器开小差了~';
//
// throw new Exception($msg); throw new Exception($msg);
//
// } }
} }
/** /**

Loading…
Cancel
Save