Skip to content

Commit 21cd90c

Browse files
committed
Move to permanent branch for laravel 6 and ES 7.17
1 parent a23bd4a commit 21cd90c

File tree

7 files changed

+432
-377
lines changed

7 files changed

+432
-377
lines changed

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
"illuminate/container": "^5.8|^6.0",
2323
"illuminate/database": "^5.8|^6.0",
2424
"illuminate/events": "^5.8|^6.0",
25-
"elasticsearch/elasticsearch": "^7.16",
26-
"ongr/elasticsearch-dsl": "^7.2"
27-
},
28-
"require-dev": {
25+
"elasticsearch/elasticsearch": "8.7"
2926
},
3027
"autoload": {
3128
"psr-4": {
@@ -38,5 +35,10 @@
3835
"PDPhilip\\Elasticsearch\\ElasticServiceProvider"
3936
]
4037
}
38+
},
39+
"config": {
40+
"allow-plugins": {
41+
"php-http/discovery": true
42+
}
4143
}
4244
}

src/Connection.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PDPhilip\Elasticsearch;
44

55
use PDPhilip\Elasticsearch\DSL\Bridge;
6-
use Elasticsearch\ClientBuilder;
6+
use Elastic\Elasticsearch\ClientBuilder;
77
use Illuminate\Database\Connection as BaseConnection;
88
use Illuminate\Support\Arr;
99
use Illuminate\Support\Str;
@@ -142,15 +142,15 @@ protected function buildConnection()
142142
{
143143
$type = config('database.connections.elasticsearch.auth_type') ?? null;
144144
$type = strtolower($type);
145-
if (!in_array($type, ['http', 'cloud', 'api'])) {
145+
if (!in_array($type, ['https', 'cloud',])) {
146146
throw new RuntimeException('Invalid [auth_type] in database config. Must be: http, cloud or api');
147147
}
148148

149149
return $this->{'_'.$type.'Connection'}();
150150

151151
}
152152

153-
protected function _httpConnection()
153+
protected function _httpsConnection()
154154
{
155155
$hosts = config('database.connections.elasticsearch.hosts') ?? null;
156156
$username = config('database.connections.elasticsearch.username') ?? null;
@@ -161,7 +161,7 @@ protected function _httpConnection()
161161
$cb->setBasicAuthentication($username, $pass)->build();
162162
}
163163
if ($certPath) {
164-
$cb->setSSLVerification($certPath);
164+
$cb->setCABundle($certPath);
165165
}
166166

167167
return $cb->build();
@@ -187,21 +187,7 @@ protected function _cloudConnection()
187187

188188
return $cb->build();
189189
}
190-
191-
192-
protected function _apiConnection()
193-
{
194-
$apiId = config('database.connections.elasticsearch.api_id') ?? null;
195-
$apiKey = config('database.connections.elasticsearch.api_key') ?? null;
196-
$certPath = config('database.connections.elasticsearch.ssl_cert') ?? null;
197-
$cb = ClientBuilder::create()->setApiKey($apiId, $apiKey);
198-
if ($certPath) {
199-
$cb->setSSLVerification($certPath);
200-
}
201-
202-
return $cb->build();
203-
}
204-
190+
205191

206192
//----------------------------------------------------------------------
207193
// Dynamic call routing to DSL bridge

0 commit comments

Comments
 (0)