|
@@ -18,7 +18,8 @@ class Es { |
|
@@ -18,7 +18,8 @@ class Es { |
18
|
// private $host = 'https://es-az664rii.public.tencentelasticsearch.com:9200'; // aicc 服务器
|
18
|
// private $host = 'https://es-az664rii.public.tencentelasticsearch.com:9200'; // aicc 服务器
|
19
|
private $host = [
|
19
|
private $host = [
|
20
|
// 'http://elastic:1qOtfZhqy4B7IXdIpl_W@192.168.80.129:9200',
|
20
|
// 'http://elastic:1qOtfZhqy4B7IXdIpl_W@192.168.80.129:9200',
|
21
|
- 'http://elastic:L6PY7r4FsHmEBYFK@127.0.0.1:9200'
|
21
|
+ 'http://elastic:L6PY7r4FsHmEBYFK@127.0.0.1:9200',
|
|
|
22
|
+// 'https://ai-email:3mLbEKwDX9YjUDFm@172.19.0.56:9200'
|
22
|
]; //内网地址 公网要加ip白名单
|
23
|
]; //内网地址 公网要加ip白名单
|
23
|
|
24
|
|
24
|
|
25
|
|
|
@@ -36,9 +37,11 @@ class Es { |
|
@@ -36,9 +37,11 @@ class Es { |
36
|
* Es constructor.
|
37
|
* Es constructor.
|
37
|
* @param $index
|
38
|
* @param $index
|
38
|
*/
|
39
|
*/
|
39
|
- public function __construct($index)
|
40
|
+ public function __construct($index,array $host=[])
|
40
|
{
|
41
|
{
|
41
|
-
|
42
|
+ if($host){
|
|
|
43
|
+ $this->host = $host;
|
|
|
44
|
+ }
|
42
|
$this->index = $index;
|
45
|
$this->index = $index;
|
43
|
|
46
|
|
44
|
$this->client = ClientBuilder::create()
|
47
|
$this->client = ClientBuilder::create()
|
|
@@ -80,7 +83,7 @@ class Es { |
|
@@ -80,7 +83,7 @@ class Es { |
80
|
try {
|
83
|
try {
|
81
|
$response = $this->client->search($params);
|
84
|
$response = $this->client->search($params);
|
82
|
}catch (\Throwable $e) {
|
85
|
}catch (\Throwable $e) {
|
83
|
- logs("搜索数据es:".$e->getMessage());
|
86
|
+ logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params));
|
84
|
return [];
|
87
|
return [];
|
85
|
}
|
88
|
}
|
86
|
|
89
|
|
|
@@ -104,7 +107,7 @@ class Es { |
|
@@ -104,7 +107,7 @@ class Es { |
104
|
try {
|
107
|
try {
|
105
|
$response = $this->client->count($params);
|
108
|
$response = $this->client->count($params);
|
106
|
}catch (\Throwable $e) {
|
109
|
}catch (\Throwable $e) {
|
107
|
- logs("搜索数据es:".$e->getMessage());
|
110
|
+ logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params));
|
108
|
return 0;
|
111
|
return 0;
|
109
|
}
|
112
|
}
|
110
|
|
113
|
|
|
@@ -129,7 +132,7 @@ class Es { |
|
@@ -129,7 +132,7 @@ class Es { |
129
|
try {
|
132
|
try {
|
130
|
$response = $this->client->get($params);
|
133
|
$response = $this->client->get($params);
|
131
|
}catch (\Throwable $e) {
|
134
|
}catch (\Throwable $e) {
|
132
|
- logs("读取数据es:".$e->getMessage());
|
135
|
+ logs("读取数据es:".$e->getMessage()." \n ".json_encode($params));
|
133
|
return [];
|
136
|
return [];
|
134
|
}
|
137
|
}
|
135
|
|
138
|
|