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,12 +294,31 @@ class SearchController extends ListDiscussionsController
return $discussions; return $discussions;
} }
protected function buildAutocompleteQuery(string $search): MatchQuery
{ protected function buildAutocompleteQuery(string $search): BoolQuery
return (new MatchQuery('title.autocomplete', $search)) {
->operator('and') $query = BoolQuery::create();
->boost(1.0);
} // Title prefix match (stronger)
$query->add(
(new MatchQuery('title.autocomplete', $search))
->operator('and')
->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;
}
/** /**
* Build the text-matching portion of the query. * Build the text-matching portion of the query.