正在显示
1 个修改的文件
包含
11 行增加
和
0 行删除
@@ -82,7 +82,9 @@ class Es { | @@ -82,7 +82,9 @@ class Es { | ||
82 | } | 82 | } |
83 | 83 | ||
84 | try { | 84 | try { |
85 | + $staTime = microtime(true); | ||
85 | $response = $this->client->search($params); | 86 | $response = $this->client->search($params); |
87 | + $this->timeLog($staTime); | ||
86 | }catch (\Throwable $e) { | 88 | }catch (\Throwable $e) { |
87 | logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params)."\n".$e->getTraceAsString()); | 89 | logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params)."\n".$e->getTraceAsString()); |
88 | return []; | 90 | return []; |
@@ -92,6 +94,13 @@ class Es { | @@ -92,6 +94,13 @@ class Es { | ||
92 | 94 | ||
93 | } | 95 | } |
94 | 96 | ||
97 | + private function timeLog($staTime){ | ||
98 | + $endTime = microtime(true); | ||
99 | + if($endTime-$staTime >= 2){ | ||
100 | + logs('查询es耗时:'.($endTime-$staTime).'s'); | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
95 | /** | 104 | /** |
96 | * 统计数量 | 105 | * 统计数量 |
97 | * @param array $body | 106 | * @param array $body |
@@ -106,7 +115,9 @@ class Es { | @@ -106,7 +115,9 @@ class Es { | ||
106 | ]; | 115 | ]; |
107 | 116 | ||
108 | try { | 117 | try { |
118 | + $staTime = microtime(true); | ||
109 | $response = $this->client->count($params); | 119 | $response = $this->client->count($params); |
120 | + $this->timeLog($staTime); | ||
110 | }catch (\Throwable $e) { | 121 | }catch (\Throwable $e) { |
111 | logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params)."\n".$e->getTraceAsString()); | 122 | logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params)."\n".$e->getTraceAsString()); |
112 | return 0; | 123 | return 0; |
-
请 注册 或 登录 后发表评论