Skip to content

Commit

Permalink
Fix completion suggesters
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Apr 19, 2024
1 parent f149556 commit 26e1332
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/Controller/InstantSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ public function __invoke(Request $request, string $query): Response
private function buildCompletionSuggesters(array $completionSuggesters): array
{
$suggestions = [];
foreach ($completionSuggesters as $field => $suggestion) {
foreach ($suggestion as $suggestionData) {
$options = $suggestionData['options'];
if (count($options) === 0) {
continue;
}
foreach ($options as $option) {
$suggestions[$field] = $option['text'];
}
foreach ($completionSuggesters as $suggestion) {
$suggestionData = reset($suggestion);
if ($suggestionData === false) {
continue;
}
$options = $suggestionData['options'];
if (count($options) === 0) {
continue;
}
foreach ($options as $option) {
$suggestions[] = $option['text'];
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/query/completion-suggesters/query.json.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"size": 5,
"skip_duplicates": true,
"fuzzy": {
"fuzziness": 2,
"fuzziness": 1,
"transpositions": true,
"min_length": 4
}
Expand Down

0 comments on commit 26e1332

Please sign in to comment.