diff --git a/src/Indexes/ElasticIndex.php b/src/Indexes/ElasticIndex.php index c95fefc..0ecd4d5 100644 --- a/src/Indexes/ElasticIndex.php +++ b/src/Indexes/ElasticIndex.php @@ -105,7 +105,6 @@ public function deleteIndex(?HTTPRequest $request = null): bool if ($this->shouldClear($request) && $this->indexExists()) { $this->getLogger()->info(sprintf('Clearing index %s', $this->getIndexName())); $deleteResult = $this->client - ->getClient() ->indices() ->delete(['index' => $this->getIndexName()]) ->asBool(); diff --git a/src/Tasks/ElasticConfigureTask.php b/src/Tasks/ElasticConfigureTask.php index 9f2efba..3a0dd63 100644 --- a/src/Tasks/ElasticConfigureTask.php +++ b/src/Tasks/ElasticConfigureTask.php @@ -18,6 +18,7 @@ use Firesphere\ElasticSearch\Indexes\ElasticIndex; use Firesphere\ElasticSearch\Services\ElasticCoreService; use Firesphere\SearchBackend\Helpers\FieldResolver; +use Firesphere\SearchBackend\Indexes\CoreIndex; use Firesphere\SearchBackend\Traits\LoggerTrait; use Psr\Container\NotFoundExceptionInterface; use SilverStripe\Control\HTTPRequest; @@ -95,8 +96,8 @@ public function run($request) /** @var ElasticIndex $instance */ $instance = Injector::inst()->get($index, false); // If delete in advance, do so - $index->deleteIndex($request); - $configResult = $this->configureIndex($instance, $request); + $instance->deleteIndex($request); + $configResult = $this->configureIndex($instance); $result[] = $configResult->asBool(); } catch (Exception $error) { // @codeCoverageIgnoreStart @@ -119,14 +120,13 @@ public function run($request) /** * Update/create a single index. * @param ElasticIndex $index - * @param HTTPRequest|null $request * @return Elasticsearch * @throws ClientResponseException * @throws MissingParameterException * @throws NotFoundExceptionInterface * @throws ServerResponseException */ - public function configureIndex($index, ?HTTPRequest $request = null): Elasticsearch + public function configureIndex(CoreIndex $index): Elasticsearch { $indexName = $index->getIndexName(); diff --git a/src/Tasks/ElasticIndexTask.php b/src/Tasks/ElasticIndexTask.php index 4e8fa71..4ca51be 100644 --- a/src/Tasks/ElasticIndexTask.php +++ b/src/Tasks/ElasticIndexTask.php @@ -132,7 +132,7 @@ public function run($request) } // If clearing, also configure if ($index->deleteIndex($request)) { - (new ElasticConfigureTask())->configureIndex($index, $request); + (new ElasticConfigureTask())->configureIndex($index); } // Get the groups diff --git a/tests/unit/Tasks/ElasticConfigureTaskTest.php b/tests/unit/Tasks/ElasticConfigureTaskTest.php index 95f900e..652182d 100644 --- a/tests/unit/Tasks/ElasticConfigureTaskTest.php +++ b/tests/unit/Tasks/ElasticConfigureTaskTest.php @@ -32,9 +32,9 @@ public function testRun() public function testConfigureIndex() { $index = new SearchIndex(); - $task = new ElasticConfigureTask(); + $result = $task->configureIndex($index); - $task->deleteIndex() + $this->assertTrue($result->asBool()); } }