From 2b7ec1deea31aa61b8cd1dfbb21a1ff5d46d8779 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 25 Nov 2016 13:34:55 -0800 Subject: [PATCH] Boost search result title matches Summary: Ref T6740. When a query matches a document title, boost results. Test Plan: - Searched for `button bar`. - Before: {F2019463} - After: {F2019470} Reviewers: chad Reviewed By: chad Maniphest Tasks: T6740 Differential Revision: https://secure.phabricator.com/D16945 --- .../PhabricatorMySQLFulltextStorageEngine.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php b/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php index a5bb2a76e2..5703efb075 100644 --- a/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php +++ b/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php @@ -197,12 +197,18 @@ final class PhabricatorMySQLFulltextStorageEngine $join = array(); $where = array(); + $title_field = PhabricatorSearchDocumentFieldType::FIELD_TITLE; + $title_boost = 1024; + $raw_query = $query->getParameter('query'); $compiled_query = $this->compileQuery($raw_query); if (strlen($compiled_query)) { $select[] = qsprintf( $conn, + 'IF(field.field = %s, %d, 0) + '. 'MATCH(corpus) AGAINST (%s IN BOOLEAN MODE) AS fieldScore', + $title_field, + $title_boost, $compiled_query); $join[] = qsprintf(