From a284ac20cbe95f0fa2730aaa57b4586a45bf6a59 Mon Sep 17 00:00:00 2001 From: Shannon Holmes Date: Thu, 24 Aug 2023 14:35:14 +1200 Subject: [PATCH 1/2] feat: add raw algolia response to access facets --- src/Service/AlgoliaQuerier.php | 3 +++ 1 file changed, 3 insertions(+) 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; } From 51396fcdadf33d36e5184e637964b05fd883e55f Mon Sep 17 00:00:00 2001 From: Shannon Holmes Date: Thu, 24 Aug 2023 14:38:36 +1200 Subject: [PATCH 2/2] fix: update index batch --- src/Tasks/AlgoliaReindex.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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;