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;
}
protected function buildAutocompleteQuery(string $search): MatchQuery
{
return (new MatchQuery('title.autocomplete', $search))
->operator('and')
->boost(1.0);
}
protected function buildAutocompleteQuery(string $search): BoolQuery
{
$query = BoolQuery::create();
// 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.