| @@ 151-163 (lines=13) @@ | ||
| 148 | * @param Client $client |
|
| 149 | * @param string $indexName Index name to delete |
|
| 150 | */ |
|
| 151 | private function deleteIndex(Client $client, $indexName) |
|
| 152 | { |
|
| 153 | try { |
|
| 154 | $path = sprintf('%s', $indexName); |
|
| 155 | $client->request($path, Request::DELETE); |
|
| 156 | } catch (ExceptionInterface $deleteOldIndexException) { |
|
| 157 | throw new \RuntimeException(sprintf( |
|
| 158 | 'Failed to delete index %s with message: %s', |
|
| 159 | $indexName, |
|
| 160 | $deleteOldIndexException->getMessage() |
|
| 161 | ), 0, $deleteOldIndexException); |
|
| 162 | } |
|
| 163 | } |
|
| 164 | ||
| 165 | /** |
|
| 166 | * Close an index. |
|
| @@ 171-187 (lines=17) @@ | ||
| 168 | * @param Client $client |
|
| 169 | * @param string $indexName |
|
| 170 | */ |
|
| 171 | private function closeIndex(Client $client, $indexName) |
|
| 172 | { |
|
| 173 | try { |
|
| 174 | $path = sprintf('%s/_close', $indexName); |
|
| 175 | $client->request($path, Request::POST); |
|
| 176 | } catch (ExceptionInterface $e) { |
|
| 177 | throw new \RuntimeException( |
|
| 178 | sprintf( |
|
| 179 | 'Failed to close index %s with message: %s', |
|
| 180 | $indexName, |
|
| 181 | $e->getMessage() |
|
| 182 | ), |
|
| 183 | 0, |
|
| 184 | $e |
|
| 185 | ); |
|
| 186 | } |
|
| 187 | } |
|
| 188 | ||
| 189 | /** |
|
| 190 | * Returns the name of a single index that an alias points to or throws |
|
| @@ 75-87 (lines=13) @@ | ||
| 72 | return 0; |
|
| 73 | } |
|
| 74 | ||
| 75 | private function deleteIndex(string $indexName): void |
|
| 76 | { |
|
| 77 | try { |
|
| 78 | $path = sprintf('%s', $indexName); |
|
| 79 | $this->client->request($path, Request::DELETE); |
|
| 80 | } catch (ExceptionInterface $deleteOldIndexException) { |
|
| 81 | throw new \RuntimeException(sprintf( |
|
| 82 | 'Failed to delete index %s with message: %s', |
|
| 83 | $indexName, |
|
| 84 | $deleteOldIndexException->getMessage() |
|
| 85 | ), 0, $deleteOldIndexException); |
|
| 86 | } |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||