Remove score display from search engine
authorChad Horohoe <chadh@wikimedia.org>
Thu, 7 Aug 2014 13:18:03 +0000 (14:18 +0100)
committerChad Horohoe <chadh@wikimedia.org>
Thu, 7 Aug 2014 13:19:37 +0000 (14:19 +0100)
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
includes/api/ApiQuerySearch.php
includes/search/SearchPostgres.php
includes/search/SearchResult.php
includes/specials/SpecialSearch.php
languages/i18n/en.json

index b84feb2..fefb594 100644 (file)
@@ -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',
index 1c41113..5ed5873 100644 (file)
@@ -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 );
                                }
index 43fb016..914bc1c 100644 (file)
@@ -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 );
-               }
-       }
 }
index 453211b..d51bff7 100644 (file)
@@ -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
         */
index 26f67b1..5f16239 100644 (file)
@@ -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 {
                                                '<td style="vertical-align: top;">' .
                                                "{$link} {$redirect} {$section} {$fileMatch}" .
                                                $extract .
-                                               "<div class='mw-search-result-data'>{$score}{$desc} - {$date}{$related}</div>" .
+                                               "<div class='mw-search-result-data'>{$desc} - {$date}{$related}</div>" .
                                                '</td>' .
                                                '</tr>' .
                                                '</table>' .
@@ -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 = "<li><div class='mw-search-result-heading'>" .
                                "{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
-                               "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
+                               "<div class='mw-search-result-data'>{$size} - {$date}{$related}</div>" .
                                "</li>\n";
                }
 
index 9ca969a..7fd6849 100644 (file)
        "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)",