diff --git a/Command/PopulateCommand.php b/Command/PopulateCommand.php
index af5fd5d..f17ca4c 100644
--- a/Command/PopulateCommand.php
+++ b/Command/PopulateCommand.php
@@ -111,7 +111,7 @@ class PopulateCommand extends ContainerAwareCommand
{
if ($reset) {
$output->writeln(sprintf('Resetting %s', $index));
- $this->resetter->resetIndex($index);
+ $this->resetter->resetIndex($index, true);
}
/** @var $providers ProviderInterface[] */
diff --git a/Index/AliasProcessor.php b/Index/AliasProcessor.php
index 5c4592d..93877cd 100644
--- a/Index/AliasProcessor.php
+++ b/Index/AliasProcessor.php
@@ -39,11 +39,13 @@ class AliasProcessor
*/
public function switchIndexAlias(IndexConfig $indexConfig, Index $index)
{
+ $client = $index->getClient();
+
$aliasName = $indexConfig->getElasticSearchName();
$oldIndexName = false;
$newIndexName = $index->getName();
- $aliasedIndexes = $this->getAliasedIndexes($aliasName);
+ $aliasedIndexes = $this->getAliasedIndexes($client, $aliasName);
if (count($aliasedIndexes) > 1) {
throw new \RuntimeException(
@@ -71,7 +73,7 @@ class AliasProcessor
);
try {
- $this->client->request('_aliases', 'POST', $aliasUpdateRequest);
+ $client->request('_aliases', 'POST', $aliasUpdateRequest);
} catch (ExceptionInterface $renameAliasException) {
$additionalError = '';
// if we failed to move the alias, delete the newly built index
@@ -96,7 +98,7 @@ class AliasProcessor
// Delete the old index after the alias has been switched
if ($oldIndexName) {
- $oldIndex = new Index($this->client, $oldIndexName);
+ $oldIndex = new Index($client, $oldIndexName);
try {
$oldIndex->delete();
} catch (ExceptionInterface $deleteOldIndexException) {
@@ -117,9 +119,9 @@ class AliasProcessor
* @param string $aliasName Alias name
* @return array
*/
- private function getAliasedIndexes($aliasName)
+ private function getAliasedIndexes(Client $client, $aliasName)
{
- $aliasesInfo = $this->client->request('_aliases', 'GET')->getData();
+ $aliasesInfo = $client->request('_aliases', 'GET')->getData();
$aliasedIndexes = array();
foreach ($aliasesInfo as $indexName => $indexInfo) {
diff --git a/Index/Resetter.php b/Index/Resetter.php
index 174c410..3f07fa1 100644
--- a/Index/Resetter.php
+++ b/Index/Resetter.php
@@ -45,10 +45,10 @@ class Resetter
/**
* Deletes and recreates all indexes
*/
- public function resetAllIndexes()
+ public function resetAllIndexes($populating = false)
{
foreach ($this->configManager->getIndexNames() as $name) {
- $this->resetIndex($name);
+ $this->resetIndex($name, $populating);
}
}