-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
… aliases
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,11 +92,49 @@ public function getClient(): Client | |
} | ||
|
||
/** | ||
* @param array<array-key, mixed>|null $createOrUpdateBody | ||
* @return Amp\Promise<bool> | ||
*/ | ||
public function setElasticSearchIndex(string $indexName, array $createOrUpdateBody = null): Amp\Promise | ||
public function indexExists(string $indexName): Amp\Promise | ||
{ | ||
return $this->client->createOrUpdateIndex($indexName, $createOrUpdateBody); | ||
return Amp\call(function () use ($indexName) { | ||
try { | ||
$response = yield $this->client->existsIndex($indexName); | ||
if ($response->getStatusCode() === 200) { | ||
return true; | ||
} | ||
return false; | ||
} catch (Error $error) { | ||
if ($error->getCode() === 404) { | ||
return false; | ||
} | ||
throw $error; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* @param array<array-key, mixed>|null $indexName | ||
*/ | ||
public function setElasticSearchIndex(string $indexName): Amp\Promise | ||
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.3
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
Check failure on line 118 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.3
|
||
{ | ||
return $this->client->createIndex($indexName); | ||
} | ||
|
||
|
||
public function setElasticSearchIndexSettings(string $indexName, array $updateSettingsBody = null): Amp\Promise | ||
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.3
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 124 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
|
||
{ | ||
return $this->client->updateIndexSettings($indexName, $updateSettingsBody); | ||
} | ||
|
||
|
||
public function setElasticSearchIndexMapping(string $indexName, array $updateMappingBody = null): Amp\Promise | ||
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.3
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 130 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
|
||
{ | ||
return $this->client->updateMappings($indexName, $updateMappingBody); | ||
} | ||
|
||
public function setElasticSearchIndexAlias(string $indexName, string $aliasName, array $aliasBody = null): Amp\Promise | ||
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.3
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 7.4
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.2
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8
Check failure on line 135 in src/Service/ElasticSearch.php GitHub Actions / PHP 8.1
|
||
{ | ||
return $this->client->createOrUpdateAlias($indexName, $aliasName, $aliasBody); | ||
} | ||
|
||
/** | ||
|