作者 邓超

调优

正在显示 1 个修改的文件 包含 10 行增加2 行删除
... ... @@ -107,7 +107,7 @@ class Es {
* @author:dc
* @time 2025/3/4 9:47
*/
public function count(array $body){
public function count(array $body, $throw = false){
$params = [
'index' => $this->getIndex(),
... ... @@ -119,11 +119,19 @@ class Es {
$response = $this->client->count($params);
$this->timeLog($staTime,$params);
}catch (\Throwable $e) {
if($throw){
throw $e;
}
logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params)."\n".$e->getTraceAsString());
return 0;
}
$ret = $response->asArray();
if(!isset($ret['count'])){
return -1;
}
return $response->asArray()['count']??0;
return $ret['count'];
}
... ...