Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft #67

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Service/AlgoliaIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function exportAttributesFromObject($item)
{
$toIndex = [
'objectID' => $item->AlgoliaUUID,
'objectContent' => $item->Content,
'objectSilverstripeID' => $item->ID,
'objectIndexedTimestamp' => date('c'),
'objectTitle' => (string) $item->Title,
Expand Down
11 changes: 11 additions & 0 deletions src/Service/AlgoliaQuerier.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ function array_key_first(array $arr)
$record = $className::get()->byId($id);

if ($record && $record->canView()) {
// Snippet results are cofigured in Algolia to be returned.
// Since the following result is actually fetched from the DB
// I need to concatenate the aogolias snippeted result to the $hit to be returned

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling mistake "algolia"

if(isset($hit["_snippetResult"]) && isset($hit["_snippetResult"]['objectContent'])) {
$record->snippetResult = $hit["_snippetResult"]['objectContent']["value"];
}

if(isset($hit["objectLink"])) {
$record->AlgoliaLink = $hit["objectLink"];
}

$records->push($record);
}
} catch (Throwable $e) {
Expand Down