r50208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50207‎ | r50208 | r50209 >
Date:23:08, 4 May 2009
Author:rainman
Status:ok (Comments)
Tags:
Comment:
Smarter searchall handling, don't rewrite the all prefix but have an extra argument
Modified paths:
  • /trunk/extensions/MWSearch/MWSearch_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MWSearch/MWSearch_body.php
@@ -10,7 +10,7 @@
1111 */
1212 function searchText( $term ) {
1313 return LuceneSearchSet::newFromQuery( isset($this->related)? 'related' : 'search',
14 - $term, $this->namespaces, $this->limit, $this->offset );
 14+ $term, $this->namespaces, $this->limit, $this->offset, $this->searchingEverything() );
1515 }
1616
1717 /**
@@ -36,6 +36,15 @@
3737
3838 return false;
3939 }
 40+
 41+ /**
 42+ * Check if we are searching all the namespaces on this wiki
 43+ *
 44+ * @return boolean
 45+ */
 46+ function searchingEverything(){
 47+ return $this->namespaces == array_keys( SearchEngine::searchableNamespaces() );
 48+ }
4049
4150 /**
4251 * Prepare query for the lucene-search daemon:
@@ -60,14 +69,8 @@
6170 $inquotes = false;
6271
6372 // "search everything" keyword
64 - $allkeyword = wfMsgForContent('searchall');
 73+ $allkeyword = wfMsgForContent('searchall');
6574
66 - // if all namespaces are set, convert to prefixed all: syntax which is more quickly handled by backend
67 - $nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
68 - if( $this->namespaces == $nsAllSet && strncmp($query, $allkeyword, strlen($allkeyword)) != 0){
69 - $query = $allkeyword.':'.$query;
70 - }
71 -
7275 $qlen = strlen($query);
7376
7477 // quick check, most of the time we don't need any rewriting
@@ -424,10 +427,13 @@
425428 * @param string $query
426429 * @param int $limit
427430 * @param int $offset
 431+ * @param bool $searchAll
428432 * @return array
429433 * @access public
430434 */
431 - static function newFromQuery( $method, $query, $namespaces = array(), $limit = 20, $offset = 0 ) {
 435+ static function newFromQuery( $method, $query, $namespaces = array(),
 436+ $limit = 20, $offset = 0, $searchAll = False ) {
 437+
432438 $fname = 'LuceneSearchSet::newFromQuery';
433439 wfProfileIn( $fname );
434440
@@ -457,6 +463,7 @@
458464 'limit' => $limit,
459465 'version' => $wgLuceneSearchVersion,
460466 'iwlimit' => 10,
 467+ 'searchall' => $searchAll? 1 : 0,
461468 ) );
462469
463470 // try to fetch cached if caching is turned on

Comments

#Comment by Brion VIBBER (talk | contribs)   21:38, 5 May 2009

Does this require a server-side update for the new parameter? If so we need to make sure updates are coordinated.

#Comment by Rainman (talk | contribs)   08:53, 6 May 2009

I've already updated the backend on all servers to the latest lucene-search version so it handles both the old and new way. So, server-wise this is ready to roll out.

Status & tagging log