From 7cb4071a5457b439e2d32128d538a436338dbd36 Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 22 Apr 2026 18:08:12 +0200 Subject: [PATCH] restore strong title match and keep prefix title fallback --- src/Api/Controllers/SearchController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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(