Add content autocomplete to search dropdown

This commit is contained in:
JM 2026-04-22 20:52:35 +02:00
parent 4538fe2ba8
commit fc830ea921
1 changed files with 25 additions and 6 deletions

View File

@ -294,11 +294,30 @@ class SearchController extends ListDiscussionsController
return $discussions;
}
protected function buildAutocompleteQuery(string $search): MatchQuery
protected function buildAutocompleteQuery(string $search): BoolQuery
{
return (new MatchQuery('title.autocomplete', $search))
$query = BoolQuery::create();
// Title prefix match (stronger)
$query->add(
(new MatchQuery('title.autocomplete', $search))
->operator('and')
->boost(1.0);
->boost(1.0),
'should'
);
// Content prefix match (weaker)
$query->add(
(new MatchQuery('content.autocomplete', $search))
->operator('and')
->boost(0.4),
'should'
);
$query->minimumShouldMatch(1);
return $query;
}
/**