diff --git a/src/Api/Controllers/SearchController.php b/src/Api/Controllers/SearchController.php index 3ec0cf9..661ad74 100644 --- a/src/Api/Controllers/SearchController.php +++ b/src/Api/Controllers/SearchController.php @@ -317,6 +317,22 @@ class SearchController extends ListDiscussionsController protected function buildTextQuery(string $search, User $actor, bool $needsScoring = false): BoolQuery { $textQuery = BoolQuery::create(); + // Strong direct title match for the full search page. + $textQuery->add( + (new MatchQuery('title', $search)) + ->operator('and') + ->boost(4.0), + 'should' + ); + + // Low-weight prefix match on title.autocomplete for partial title hits. + $textQuery->add( + (new MatchQuery('title.autocomplete', $search)) + ->operator('and') + ->boost(0.35), + 'should' + ); + // Low-weight prefix match on title.autocomplete for the full search page. // Exact / normal title matches should still rank higher than prefix-only hits. $textQuery->add(