2
2
3
3
namespace Sineflow \ElasticsearchBundle \Manager ;
4
4
5
+ use Elasticsearch \Common \Exceptions \ElasticsearchException ;
5
6
use Elasticsearch \Common \Exceptions \Missing404Exception ;
6
7
use Sineflow \ElasticsearchBundle \Document \DocumentInterface ;
7
8
use Sineflow \ElasticsearchBundle \Document \Provider \ProviderInterface ;
@@ -344,7 +345,7 @@ public function getReadIndices()
344
345
*
345
346
* @throws IndexOrAliasNotFoundException
346
347
*/
347
- protected function getWriteIndices ()
348
+ public function getWriteIndices ()
348
349
{
349
350
return $ this ->getIndicesForAlias ($ this ->writeAlias );
350
351
}
@@ -477,7 +478,7 @@ public function rebuildIndex($deleteOld = false, $cancelExistingRebuild = false)
477
478
];
478
479
$ this ->getConnection ()->getClient ()->indices ()->updateAliases ($ setAliasParams );
479
480
480
- $ this ->copyDataFromOldToNewIndex ($ newIndex );
481
+ $ this ->copyDataFromOldToNewIndex ($ newIndex, $ oldIndex );
481
482
482
483
// Point both aliases to the new index and remove them from the old
483
484
$ setAliasParams = [
@@ -496,9 +497,10 @@ public function rebuildIndex($deleteOld = false, $cancelExistingRebuild = false)
496
497
$ this ->getConnection ()->getClient ()->indices ()->delete (['index ' => $ oldIndex ]);
497
498
$ this ->getConnection ()->getLogger ()->notice (sprintf ('Deleted old index %s ' , $ oldIndex ));
498
499
}
499
- } catch (Exception $ e ) {
500
- // Bulk exceptions are logged in the connection manager, so only log other exceptions here
501
- if (!($ e instanceof BulkRequestException)) {
500
+ } catch (\Exception $ e ) {
501
+ // Do not log BulkRequestException here as they are logged in the connection manager
502
+ // Do not log ElasticsearchException either, as they are logged inside the elasticsearch bundle
503
+ if (!($ e instanceof BulkRequestException) && !($ e instanceof ElasticsearchException)) {
502
504
$ this ->getConnection ()->getLogger ()->error ($ e ->getMessage ());
503
505
}
504
506
@@ -682,8 +684,9 @@ protected function createNewIndexWithUniqueName()
682
684
* Retrieves all documents from the index's data provider and populates them in a new index
683
685
*
684
686
* @param string $newIndex
687
+ * @param string $oldIndex
685
688
*/
686
- protected function copyDataFromOldToNewIndex (string $ newIndex )
689
+ protected function copyDataFromOldToNewIndex (string $ newIndex, string $ oldIndex )
687
690
{
688
691
$ batchSize = $ this ->connection ->getConnectionSettings ()['bulk_batch_size ' ];
689
692
0 commit comments