Skip to content

Commit

Permalink
[5.x] Include Algolia highlights and snippets (statamic#11008)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksleight authored Oct 25, 2024
1 parent 4d08876 commit 1a3e110
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Search/Algolia/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Statamic\Search\Documents;
use Statamic\Search\Index as BaseIndex;
use Statamic\Search\IndexNotFoundException;
use Statamic\Search\Result;
use Statamic\Support\Str;

class Index extends BaseIndex
Expand Down Expand Up @@ -120,4 +121,12 @@ private function handleAlgoliaException($e)

throw $e;
}

public function extraAugmentedResultData(Result $result)
{
return [
'search_highlights' => $result->getRawResult()['_highlightResult'] ?? null,
'search_snippets' => $result->getRawResult()['_snippetResult'] ?? null,
];
}
}

0 comments on commit 1a3e110

Please sign in to comment.