r38110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38109‎ | r38110 | r38111 >
Date:21:31, 27 July 2008
Author:brion
Status:old
Tags:
Comment:
* API search now falls back to fulltext search by default when using Lucene
or other engine which doesn't support a separate title search function.
This means you can use API search on Wikipedia without explicitly adding
&srwhat=text to the query.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuerySearch.php
@@ -53,6 +53,7 @@
5454
5555 $limit = $params['limit'];
5656 $query = $params['search'];
 57+ $what = $params['what'];
5758 if (is_null($query) || empty($query))
5859 $this->dieUsage("empty search string is not allowed", 'param-search');
5960
@@ -61,13 +62,27 @@
6263 $search->setNamespaces( $params['namespace'] );
6364 $search->showRedirects = $params['redirects'];
6465
65 - if ($params['what'] == 'text')
 66+ if ($what == 'text') {
6667 $matches = $search->searchText( $query );
67 - else
 68+ } elseif( $what == 'title' ) {
6869 $matches = $search->searchTitle( $query );
 70+ } else {
 71+ // We default to title searches; this is a terrible legacy
 72+ // of the way we initially set up the MySQL fulltext-based
 73+ // search engine with separate title and text fields.
 74+ // In the future, the default should be for a combined index.
 75+ $matches = $search->searchTitle( $query );
 76+
 77+ // Not all search engines support a separate title search,
 78+ // for instance the Lucene-based engine we use on Wikipedia.
 79+ // In this case, fall back to full-text search (which will
 80+ // include titles in it!)
 81+ if( is_null( $matches ) )
 82+ $matches = $search->searchText( $query );
 83+ }
6984 if (is_null($matches))
70 - $this->dieUsage("{$params['what']} search is disabled",
71 - "search-{$params['what']}-disabled");
 85+ $this->dieUsage("{$what} search is disabled",
 86+ "search-{$what}-disabled");
7287
7388 $data = array ();
7489 $count = 0;
@@ -109,7 +124,7 @@
110125 ApiBase :: PARAM_ISMULTI => true,
111126 ),
112127 'what' => array (
113 - ApiBase :: PARAM_DFLT => 'title',
 128+ ApiBase :: PARAM_DFLT => null,
114129 ApiBase :: PARAM_TYPE => array (
115130 'title',
116131 'text',
Index: trunk/phase3/RELEASE-NOTES
@@ -45,7 +45,12 @@
4646
4747 * Registration time of users registered before the DB field was created is now
4848 shown as empty instead of the current time.
 49+* API search now falls back to fulltext search by default when using Lucene
 50+ or other engine which doesn't support a separate title search function.
 51+ This means you can use API search on Wikipedia without explicitly adding
 52+ &srwhat=text to the query.
4953
 54+
5055 === Languages updated in 1.14 ===
5156
5257 MediaWiki supports over 300 languages. Many localisations are updated

Status & tagging log