...
|
...
|
@@ -18,7 +18,8 @@ class Es { |
|
|
// private $host = 'https://es-az664rii.public.tencentelasticsearch.com:9200'; // aicc 服务器
|
|
|
private $host = [
|
|
|
// 'http://elastic:1qOtfZhqy4B7IXdIpl_W@192.168.80.129:9200',
|
|
|
'http://elastic:L6PY7r4FsHmEBYFK@127.0.0.1:9200'
|
|
|
'http://elastic:L6PY7r4FsHmEBYFK@127.0.0.1:9200',
|
|
|
// 'https://ai-email:3mLbEKwDX9YjUDFm@172.19.0.56:9200'
|
|
|
]; //内网地址 公网要加ip白名单
|
|
|
|
|
|
|
...
|
...
|
@@ -36,9 +37,11 @@ class Es { |
|
|
* Es constructor.
|
|
|
* @param $index
|
|
|
*/
|
|
|
public function __construct($index)
|
|
|
public function __construct($index,array $host=[])
|
|
|
{
|
|
|
|
|
|
if($host){
|
|
|
$this->host = $host;
|
|
|
}
|
|
|
$this->index = $index;
|
|
|
|
|
|
$this->client = ClientBuilder::create()
|
...
|
...
|
@@ -80,7 +83,7 @@ class Es { |
|
|
try {
|
|
|
$response = $this->client->search($params);
|
|
|
}catch (\Throwable $e) {
|
|
|
logs("搜索数据es:".$e->getMessage());
|
|
|
logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params));
|
|
|
return [];
|
|
|
}
|
|
|
|
...
|
...
|
@@ -104,7 +107,7 @@ class Es { |
|
|
try {
|
|
|
$response = $this->client->count($params);
|
|
|
}catch (\Throwable $e) {
|
|
|
logs("搜索数据es:".$e->getMessage());
|
|
|
logs("搜索数据es:".$e->getMessage()." \n ".json_encode($params));
|
|
|
return 0;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -129,7 +132,7 @@ class Es { |
|
|
try {
|
|
|
$response = $this->client->get($params);
|
|
|
}catch (\Throwable $e) {
|
|
|
logs("读取数据es:".$e->getMessage());
|
|
|
logs("读取数据es:".$e->getMessage()." \n ".json_encode($params));
|
|
|
return [];
|
|
|
}
|
|
|
|
...
|
...
|
|