diff --git a/src/Service/AlgoliaQuerier.php b/src/Service/AlgoliaQuerier.php index 2add0b6..54bc3c4 100644 --- a/src/Service/AlgoliaQuerier.php +++ b/src/Service/AlgoliaQuerier.php @@ -88,6 +88,9 @@ function array_key_first(array $arr) ->setPageLength($results['hitsPerPage']); } + // add raw output from algoia for manipulation + $output->raw = $results; + return $output; } diff --git a/src/Tasks/AlgoliaReindex.php b/src/Tasks/AlgoliaReindex.php index 33f5ed3..8b787ae 100644 --- a/src/Tasks/AlgoliaReindex.php +++ b/src/Tasks/AlgoliaReindex.php @@ -295,17 +295,15 @@ public function indexItems($indexName, $items = null, $output = true) public function indexBatch($indexName, $items): bool { $service = Injector::inst()->create(AlgoliaService::class); - $indexes = $service->getIndexByName($indexName); + $index = $service->getIndexByName($indexName); try { - foreach ($indexes as $index) { - $result = $index->saveObjects($items, [ - 'autoGenerateObjectIDIfNotExist' => true - ]); + $result = $index->saveObjects($items, [ + 'autoGenerateObjectIDIfNotExist' => true + ]); - if (!$result->valid()) { - return false; - } + if (!$result->valid()) { + return false; } return true;