From af87cb4a3f528859bbe89df5db49f35fec07d9e5 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 7 Aug 2014 14:18:03 +0100 Subject: [PATCH] Remove score display from search engine Scores are an internal metric that should not be exposed to users, plus most backends fail to even support it. Removes PostgresSearch*-specific result classes as they're not needed anymore. Change-Id: I00acaabad0565b9a5b3524c992feea366eb74bcc --- includes/AutoLoader.php | 2 -- includes/api/ApiQuerySearch.php | 3 --- includes/search/SearchPostgres.php | 34 +++-------------------------- includes/search/SearchResult.php | 7 ------ includes/specials/SpecialSearch.php | 15 +++---------- languages/i18n/en.json | 1 - 6 files changed, 6 insertions(+), 56 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index b84feb20c4..fefb59471d 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -907,8 +907,6 @@ $wgAutoloadLocalClasses = array( 'RevisionDeleteUser' => 'includes/revisiondelete/RevisionDeleteUser.php', # includes/search - 'PostgresSearchResult' => 'includes/search/SearchPostgres.php', - 'PostgresSearchResultSet' => 'includes/search/SearchPostgres.php', 'SearchDatabase' => 'includes/search/SearchDatabase.php', 'SearchEngine' => 'includes/search/SearchEngine.php', 'SearchEngineDummy' => 'includes/search/SearchEngine.php', diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 1c411134d8..5ed5873346 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -157,9 +157,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { if ( isset( $prop['timestamp'] ) ) { $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $result->getTimestamp() ); } - if ( !is_null( $result->getScore() ) && isset( $prop['score'] ) ) { - $vals['score'] = $result->getScore(); - } if ( isset( $prop['titlesnippet'] ) ) { $vals['titlesnippet'] = $result->getTitleSnippet( $terms ); } diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 43fb0169d5..914bc1c493 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -35,14 +35,14 @@ class SearchPostgres extends SearchDatabase { * latest revision article text (pagecontent.old_text) * * @param string $term Raw search term - * @return PostgresSearchResultSet + * @return SqlSearchResultSet */ function searchTitle( $term ) { $q = $this->searchQuery( $term, 'titlevector', 'page_title' ); $olderror = error_reporting( E_ERROR ); $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) ); error_reporting( $olderror ); - return new PostgresSearchResultSet( $resultSet, $this->searchTerms ); + return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } function searchText( $term ) { @@ -50,7 +50,7 @@ class SearchPostgres extends SearchDatabase { $olderror = error_reporting( E_ERROR ); $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) ); error_reporting( $olderror ); - return new PostgresSearchResultSet( $resultSet, $this->searchTerms ); + return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } /** @@ -195,32 +195,4 @@ class SearchPostgres extends SearchDatabase { return true; } -} ## end of the SearchPostgres class - -/** - * @ingroup Search - */ -class PostgresSearchResult extends SearchResult { - function __construct( $row ) { - parent::__construct( $row ); - $this->score = $row->score; - } - - function getScore() { - return $this->score; - } -} - -/** - * @ingroup Search - */ -class PostgresSearchResultSet extends SqlSearchResultSet { - function next() { - $row = $this->resultSet->fetchObject(); - if ( $row === false ) { - return false; - } else { - return new PostgresSearchResult( $row ); - } - } } diff --git a/includes/search/SearchResult.php b/includes/search/SearchResult.php index 453211be96..d51bff7cdd 100644 --- a/includes/search/SearchResult.php +++ b/includes/search/SearchResult.php @@ -142,13 +142,6 @@ class SearchResult { return $this->mImage; } - /** - * @return float|null If not supported - */ - function getScore() { - return null; - } - /** * Lazy initialization of article text from DB */ diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 26f67b1c09..5f1623927c 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -651,16 +651,6 @@ class SpecialSearch extends SpecialPage { $lang = $this->getLanguage(); - // format score - if ( is_null( $result->getScore() ) ) { - // Search engine doesn't report scoring info - $score = ''; - } else { - $percent = sprintf( '%2.1f', $result->getScore() * 100 ); - $score = $this->msg( 'search-result-score' )->numParams( $percent )->text() - . ' - '; - } - // format description $byteSize = $result->getByteSize(); $wordCount = $result->getWordCount(); @@ -722,7 +712,7 @@ class SpecialSearch extends SpecialPage { '' . "{$link} {$redirect} {$section} {$fileMatch}" . $extract . - "
{$score}{$desc} - {$date}{$related}
" . + "
{$desc} - {$date}{$related}
" . '' . '' . '' . @@ -733,6 +723,7 @@ class SpecialSearch extends SpecialPage { $html = null; + $score = ''; if ( wfRunHooks( 'ShowSearchHit', array( $this, $result, $terms, &$link, &$redirect, &$section, &$extract, @@ -741,7 +732,7 @@ class SpecialSearch extends SpecialPage { ) ) ) { $html = "
  • " . "{$link} {$redirect} {$section} {$fileMatch}
    {$extract}\n" . - "
    {$score}{$size} - {$date}{$related}
    " . + "
    {$size} - {$date}{$related}
    " . "
  • \n"; } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 9ca969a092..7fd6849539 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -885,7 +885,6 @@ "searchprofile-advanced-tooltip": "Search in custom namespaces", "search-result-size": "$1 ({{PLURAL:$2|1 word|$2 words}})", "search-result-category-size": "{{PLURAL:$1|1 member|$1 members}} ({{PLURAL:$2|1 subcategory|$2 subcategories}}, {{PLURAL:$3|1 file|$3 files}})", - "search-result-score": "Relevance: $1%", "search-redirect": "(redirect $1)", "search-section": "(section $1)", "search-file-match": "(matches file content)", -- 2.20.1