completionSearch: try an exact match even if the backend returns no result
authordcausse <dcausse@wikimedia.org>
Fri, 11 Mar 2016 08:30:34 +0000 (09:30 +0100)
committerdcausse <dcausse@wikimedia.org>
Fri, 11 Mar 2016 08:40:40 +0000 (09:40 +0100)
Unfortunately some backends (like Cirrus) are not able to do proper crossnamespace
lookup. If the backend returns no result we should still try an exact title match.

Bug:T129575
Change-Id: Ic08ec0aac0fd8a289f21753d74ae62ba509de841

includes/search/SearchEngine.php

index 1344f4c..b263fb3 100644 (file)
@@ -708,10 +708,6 @@ class SearchEngine {
         * @return SearchSuggestionSet
         */
        protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
-               if ( $suggestions->getSize() == 0 ) {
-                       // If we don't have anything, don't bother
-                       return $suggestions;
-               }
                $search = trim( $search );
                // preload the titles with LinkBatch
                $titles = $suggestions->map( function( SearchSuggestion $sugg ) {
@@ -726,6 +722,10 @@ class SearchEngine {
                } );
 
                // Rescore results with an exact title match
+               // NOTE: in some cases like cross-namespace redirects
+               // (frequently used as shortcuts e.g. WP:WP on huwiki) some
+               // backends like Cirrus will return no results. We should still
+               // try an exact title match to workaround this limitation
                $rescorer = new SearchExactMatchRescorer();
                $rescoredResults = $rescorer->rescore( $search, $this->namespaces, $results, $this->limit );