r96431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96430‎ | r96431 | r96432 >
Date:13:36, 7 September 2011
Author:svemir
Status:deferred
Tags:
Comment:
implement SearchEngine getTotalHits and getInfo methods
Modified paths:
  • /trunk/extensions/SphinxSearch/SphinxMWSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SphinxSearch/SphinxMWSearch.php
@@ -163,13 +163,14 @@
164164 var $sphinx_client;
165165 var $mSuggestion = '';
166166 var $db;
 167+ var $total_hits = 0;
167168
168169 function __construct( $resultSet, $terms, $sphinx_client, $dbr ) {
169170 $this->sphinx_client = $sphinx_client;
170171 $this->mResultSet = array();
171172 $this->db = $dbr ? $dbr : wfGetDB( DB_SLAVE );
172 -
173173 if ( is_array( $resultSet ) && isset( $resultSet['matches'] ) ) {
 174+ $this->total_hits = $resultSet[ 'total_found' ];
174175 foreach ( $resultSet['matches'] as $id => $docinfo ) {
175176 $res = $this->db->select(
176177 'page',
@@ -346,6 +347,29 @@
347348 }
348349
349350 /**
 351+ * Some search modes return a total hit count for the query
 352+ * in the entire article database. This may include pages
 353+ * in namespaces that would not be matched on the given
 354+ * settings.
 355+ *
 356+ * Return null if no total hits number is supported.
 357+ *
 358+ * @return Integer
 359+ */
 360+ function getTotalHits() {
 361+ return $this->total_hits;
 362+ }
 363+
 364+ /**
 365+ * Return information about how and from where the results were fetched.
 366+ *
 367+ * @return string
 368+ */
 369+ function getInfo() {
 370+ return wfMsg( 'sphinxPowered', "http://www.sphinxsearch.com" );
 371+ }
 372+
 373+ /**
350374 * @return SphinxMWSearchResult: next result, false if none
351375 */
352376 function next() {

Status & tagging log