MediaWiki  REL1_22
SearchEngine Class Reference

Contain a class for special pages. More...

Inheritance diagram for SearchEngine:
Collaboration diagram for SearchEngine:

List of all members.

Public Member Functions

 __construct ($db=null)
 acceptListRedirects ()
 If this search backend can list/unlist redirects.
 delete ($id, $title)
 Delete an indexed page Title should be pre-processed.
 filter ($text)
 Return a 'cleaned up' search string.
 getTextFromContent (Title $t, Content $c=null)
 Get the raw text for updating the index from a content object Nicer search backends could possibly do something cooler than just returning raw text.
 normalizeText ($string)
 When overridden in derived class, performs database-specific conversions on text to be used for searching or updating search index.
 replacePrefixes ($query)
 Parse some common prefixes: all (search everything) or namespace names.
 searchText ($term)
 Perform a full text search query and return a result set.
 searchTitle ($term)
 Perform a title-only search query and return a result set.
 setFeatureData ($feature, $data)
 Way to pass custom data for engines.
 setLimitOffset ($limit, $offset=0)
 Set the maximum number of results to return and how many to skip before returning the first.
 setNamespaces ($namespaces)
 Set which namespaces the search should include.
 supports ($feature)
 textAlreadyUpdatedForIndex ()
 If an implementation of SearchEngine handles all of its own text processing in getTextFromContent() and doesn't require SearchUpdate::updateText()'s rather silly handling, it should return true here instead.
 transformSearchTerm ($term)
 Transform search term in cases when parts of the query came as different GET params (when supported) e.g.
 update ($id, $title, $text)
 Create or update the search index record for the given page.
 updateTitle ($id, $title)
 Update a search index record's title only.

Static Public Member Functions

static create ($type=null)
 Load up the appropriate search engine class for the currently active database backend, and return a configured instance.
static defaultNamespaces ()
 An array of namespaces indexes to be searched by default.
static getNearMatch ($searchterm)
 If an exact title match can be found, or a very slightly close match, return the title.
static getNearMatchResultSet ($searchterm)
 Do a near match (see SearchEngine::getNearMatch) and wrap it into a SearchResultSet.
static getOpenSearchTemplate ()
 Get OpenSearch suggestion template.
static getSearchTypes ()
 Return the search engines we support.
static helpNamespaces ()
 Return the help namespaces to be shown on Special:Search.
static legalSearchChars ()
static namespacesAsText ($namespaces)
 Get a list of namespace names useful for showing in tooltips and preferences.
static searchableNamespaces ()
 Make a list of searchable namespaces and their canonical names.
static userHighlightPrefs ()
 Find snippet highlight settings for all users.
static userNamespaces ($user)
 Extract default namespaces to search from the given user's settings, returning a list of index numbers.

Public Attributes

 $limit = 10
 $namespaces = array( NS_MAIN )
 $offset = 0
 $prefix = ''
 $searchTerms = array()
 $showRedirects = false

Protected Attributes

DatabaseBase $db
 $features = array()
 Feature values.

Static Private Member Functions

static getNearMatchInternal ($searchterm)
 Really find the title match.

Detailed Description

Contain a class for special pages.

Definition at line 32 of file SearchEngine.php.


Constructor & Destructor Documentation

SearchEngine::__construct ( db = null)

Reimplemented in SearchOracle, SearchPostgres, SearchMySQL, SearchSqlite, SearchMssql, and MockSearch.

Definition at line 47 of file SearchEngine.php.

References $db, and wfGetDB().


Member Function Documentation

If this search backend can list/unlist redirects.

Deprecated:
since 1.18 Call supports( 'list-redirects' );
Returns:
bool

Definition at line 84 of file SearchEngine.php.

static SearchEngine::create ( type = null) [static]

Load up the appropriate search engine class for the currently active database backend, and return a configured instance.

Parameters:
String$typeType of search backend, if not the default
Returns:
SearchEngine

Definition at line 459 of file SearchEngine.php.

Referenced by SearchResult\initText(), and ApiQuerySearch\run().

static SearchEngine::defaultNamespaces ( ) [static]

An array of namespaces indexes to be searched by default.

Returns:
Array

Definition at line 406 of file SearchEngine.php.

Referenced by SpecialSearch\getSearchProfiles(), and SpecialSearchTest\provideSearchOptionsTests().

SearchEngine::delete ( id,
title 
)

Delete an indexed page Title should be pre-processed.

STUB

Parameters:
Integer$idPage id that was deleted
String$titleTitle of page that was deleted

Reimplemented in SearchMySQL.

Definition at line 528 of file SearchEngine.php.

SearchEngine::filter ( text)

Return a 'cleaned up' search string.

Parameters:
$textString
Returns:
String

Definition at line 448 of file SearchEngine.php.

Referenced by SearchSqlite\searchInternal(), and SearchMySQL\searchInternal().

static SearchEngine::getNearMatch ( searchterm) [static]

If an exact title match can be found, or a very slightly close match, return the title.

If no match, returns NULL.

Parameters:
$searchtermString
Returns:
Title

Definition at line 146 of file SearchEngine.php.

static SearchEngine::getNearMatchInternal ( searchterm) [static, private]

Really find the title match.

Returns:
null|Title

Definition at line 168 of file SearchEngine.php.

static SearchEngine::getNearMatchResultSet ( searchterm) [static]

Do a near match (see SearchEngine::getNearMatch) and wrap it into a SearchResultSet.

Parameters:
$searchtermstring
Returns:
SearchResultSet

Definition at line 160 of file SearchEngine.php.

Referenced by ApiQuerySearch\run().

Get OpenSearch suggestion template.

Returns:
String

Definition at line 537 of file SearchEngine.php.

static SearchEngine::getSearchTypes ( ) [static]

Return the search engines we support.

If only $wgSearchType is set, it'll be an array of just that one item.

Returns:
array

Definition at line 485 of file SearchEngine.php.

Referenced by ApiQuerySearch\getAllowedParams(), and ApiQuerySearch\getParamDescription().

SearchEngine::getTextFromContent ( Title t,
Content c = null 
)

Get the raw text for updating the index from a content object Nicer search backends could possibly do something cooler than just returning raw text.

Todo:
This isn't ideal, we'd really like to have content-specific handling here
Parameters:
Title$tTitle we're indexing
Content$cContent of the page to index
Returns:
string

Definition at line 560 of file SearchEngine.php.

static SearchEngine::helpNamespaces ( ) [static]

Return the help namespaces to be shown on Special:Search.

Returns:
Array

Definition at line 436 of file SearchEngine.php.

Referenced by SpecialSearch\getSearchProfiles().

static SearchEngine::legalSearchChars ( ) [static]

Reimplemented in SearchOracle, SearchMySQL, and SearchSqlite.

Definition at line 280 of file SearchEngine.php.

Referenced by Title\indexTitle(), and SearchMssql\parseQuery().

static SearchEngine::namespacesAsText ( namespaces) [static]

Get a list of namespace names useful for showing in tooltips and preferences.

Parameters:
$namespacesArray
Returns:
array

Definition at line 419 of file SearchEngine.php.

Referenced by SpecialSearch\getSearchProfiles().

When overridden in derived class, performs database-specific conversions on text to be used for searching or updating search index.

Default implementation does nothing (simply returns $string).

Parameters:
string$stringString to process
Returns:
string

Reimplemented in SearchMySQL.

Definition at line 124 of file SearchEngine.php.

Parse some common prefixes: all (search everything) or namespace names.

Parameters:
$queryString
Returns:
string

Definition at line 313 of file SearchEngine.php.

Make a list of searchable namespaces and their canonical names.

Returns:
Array

Definition at line 347 of file SearchEngine.php.

Referenced by SpecialSearch\getSearchProfiles(), and Preferences\loadOldSearchNs().

Perform a full text search query and return a result set.

If title searches are not supported or disabled, return null. STUB

Parameters:
string$termraw search term
Returns:
SearchResultSet|Status|null

Reimplemented in SearchMySQL, SearchSqlite, SearchOracle, SearchPostgres, and SearchMssql.

Definition at line 63 of file SearchEngine.php.

Perform a title-only search query and return a result set.

If title searches are not supported or disabled, return null. STUB

Parameters:
string$termraw search term
Returns:
SearchResultSet|null

Reimplemented in SearchMySQL, SearchSqlite, SearchOracle, SearchMssql, and SearchPostgres.

Definition at line 75 of file SearchEngine.php.

SearchEngine::setFeatureData ( feature,
data 
)

Way to pass custom data for engines.

Since:
1.18
Parameters:
$featureString
$dataMixed
Returns:
bool

Definition at line 112 of file SearchEngine.php.

SearchEngine::setLimitOffset ( limit,
offset = 0 
)

Set the maximum number of results to return and how many to skip before returning the first.

Parameters:
$limitInteger
$offsetInteger

Definition at line 291 of file SearchEngine.php.

SearchEngine::setNamespaces ( namespaces)

Set which namespaces the search should include.

Give an array of namespace index numbers.

Parameters:
$namespacesArray

Definition at line 302 of file SearchEngine.php.

SearchEngine::supports ( feature)
Since:
1.18
Parameters:
$featureString
Returns:
Boolean

Reimplemented in SearchMySQL.

Definition at line 94 of file SearchEngine.php.

If an implementation of SearchEngine handles all of its own text processing in getTextFromContent() and doesn't require SearchUpdate::updateText()'s rather silly handling, it should return true here instead.

Returns:
bool

Definition at line 571 of file SearchEngine.php.

Transform search term in cases when parts of the query came as different GET params (when supported) e.g.

for prefix queries: search=test&prefix=Main_Page/Archive -> test prefix:Main Page/Archive

Definition at line 135 of file SearchEngine.php.

SearchEngine::update ( id,
title,
text 
)

Create or update the search index record for the given page.

Title and text should be pre-processed. STUB

Parameters:
$idInteger
$titleString
$textString

Reimplemented in SearchMySQL, SearchSqlite, SearchOracle, SearchPostgres, SearchMssql, and MockSearch.

Definition at line 504 of file SearchEngine.php.

SearchEngine::updateTitle ( id,
title 
)

Update a search index record's title only.

Title should be pre-processed. STUB

Parameters:
$idInteger
$titleString

Reimplemented in SearchMySQL, SearchSqlite, SearchOracle, SearchMssql, and SearchPostgres.

Definition at line 516 of file SearchEngine.php.

static SearchEngine::userHighlightPrefs ( ) [static]

Find snippet highlight settings for all users.

Returns:
Array contextlines, contextchars

Definition at line 395 of file SearchEngine.php.

static SearchEngine::userNamespaces ( user) [static]

Extract default namespaces to search from the given user's settings, returning a list of index numbers.

Parameters:
$userUser
Returns:
Array

Definition at line 367 of file SearchEngine.php.


Member Data Documentation

DatabaseBase SearchEngine::$db [protected]
SearchEngine::$features = array() [protected]

Feature values.

Definition at line 41 of file SearchEngine.php.

SearchEngine::$limit = 10

Definition at line 33 of file SearchEngine.php.

SearchEngine::$namespaces = array( NS_MAIN )

Definition at line 37 of file SearchEngine.php.

Referenced by SearchMssql\queryNamespaces(), and SearchOracle\queryNamespaces().

SearchEngine::$offset = 0

Definition at line 34 of file SearchEngine.php.

SearchEngine::$prefix = ''

Definition at line 35 of file SearchEngine.php.

SearchEngine::$searchTerms = array()

Definition at line 36 of file SearchEngine.php.

SearchEngine::$showRedirects = false

Definition at line 38 of file SearchEngine.php.


The documentation for this class was generated from the following file: