Skip to content

Commit 5264906

Browse files
committed
FEATURE: Make enabling autocomplete / suggestions configurable
1 parent c159524 commit 5264906

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Classes/Controller/SuggestController.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ protected function buildRequestForTerm(string $term, string $contextNodeIdentifi
129129
->queryFilter('prefix', [
130130
'neos_completion' => $termPlaceholder
131131
])
132-
->limit(0)
133-
->aggregation('autocomplete', [
132+
->limit(0);
133+
134+
if (($this->searchAsYouTypeSettings['autocomplete']['enabled'] ?? false) === true) {
135+
$query->aggregation('autocomplete', [
134136
'terms' => [
135137
'field' => 'neos_completion',
136138
'order' => [
@@ -139,8 +141,11 @@ protected function buildRequestForTerm(string $term, string $contextNodeIdentifi
139141
'include' => $termPlaceholder . '.*',
140142
'size' => $this->searchAsYouTypeSettings['autocomplete']['size'] ?? 10
141143
]
142-
])
143-
->suggestions('suggestions', [
144+
]);
145+
}
146+
147+
if (($this->searchAsYouTypeSettings['suggestions']['enabled'] ?? false) === true) {
148+
$query->suggestions('suggestions', [
144149
'prefix' => $termPlaceholder,
145150
'completion' => [
146151
'field' => 'neos_suggestion',
@@ -152,6 +157,7 @@ protected function buildRequestForTerm(string $term, string $contextNodeIdentifi
152157
]
153158
]
154159
]);
160+
}
155161

156162
$request = $query->getRequest()->toArray();
157163

Configuration/Settings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ Flowpack:
33
searchAsYouType:
44
autocomplete:
55
size: 10
6+
enabled: true
67
suggestions:
78
size: 10
9+
enabled: true
810
sourceFields:
911
- neos_path
1012
- title

0 commit comments

Comments
 (0)