diff --git a/src/Processors/SuggestionsProcessor.php b/src/Processors/SuggestionsProcessor.php index 549e96b..c2dfae5 100644 --- a/src/Processors/SuggestionsProcessor.php +++ b/src/Processors/SuggestionsProcessor.php @@ -4,6 +4,7 @@ use Exception; use SilverStripe\Core\Injector\Injectable; +use SilverStripe\Discoverer\Service\Results\Field; use SilverStripe\Discoverer\Service\Results\Suggestions; class SuggestionsProcessor @@ -19,7 +20,14 @@ public function getProcessedSuggestions(Suggestions $suggestions, array $respons // Check that we have all critical fields in our Elastic response $this->validateResponse($response); - $suggestions->setSuggestions($response['results'] ?? []); + $results = $response['results'] ?? []; + + foreach ($results as $result) { + $suggestions->addSuggestion(Field::create( + $result['raw'] ?? null, + $result['snippet'] ?? null, + )); + } } private function validateResponse(array $response): void