X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fsearch%2FSearchEngine.php;h=90bfebd21319bb753314d7cd5bf6bfc879c6a8b6;hp=696facba4401717d9678f5d41ddb2cb3d2d2d08d;hb=7874fc4bec845ad92960b07e969c65f3c3fe74f2;hpb=5e8896ce39894b9c705a291525c6735a576b6b1c diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 696facba44..90bfebd213 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -547,13 +547,20 @@ abstract class SearchEngine { return $sugg->getSuggestedTitle()->getPrefixedText(); } ); - // 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 ); + if ( $this->offset === 0 ) { + // 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 ); + } else { + // No need to rescore if offset is not 0 + // The exact match must have been returned at position 0 + // if it existed. + $rescoredResults = $results; + } if ( count( $rescoredResults ) > 0 ) { $found = array_search( $rescoredResults[0], $results );