MediaWiki REL1_33
|
Contain a class for special pages. More...
Public Member Functions | |
augmentSearchResults (SearchResultSet $resultSet) | |
Augment search results with extra data. | |
completionSearch ( $search) | |
Perform a completion search. | |
completionSearchWithVariants ( $search) | |
Perform a completion search with variants. | |
defaultPrefixSearch ( $search) | |
Simple prefix search for subpages. | |
delete ( $id, $title) | |
Delete an indexed page Title should be pre-processed. | |
extractTitles (SearchSuggestionSet $completionResults) | |
Extract titles from completion results. | |
getFeatureData ( $feature) | |
Way to retrieve custom data set by setFeatureData or by the engine itself. | |
getNearMatcher (Config $config) | |
Get service class to finding near matches. | |
getProfiles ( $profileType, User $user=null) | |
Get a list of supported profiles. | |
getSearchIndexFields () | |
Get fields for search index. | |
getSort () | |
Get the sort direction of the search results. | |
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. | |
getValidSorts () | |
Get the valid sort directions. | |
makeSearchFieldMapping ( $name, $type) | |
Create a search field definition. | |
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 and set the list of namespaces of this class accordingly. | |
searchArchiveTitle ( $term) | |
Perform a title search in the article archive. | |
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. | |
setShowSuggestion ( $showSuggestion) | |
Set whether the searcher should try to build a suggestion. | |
setSort ( $sort) | |
Set the sort direction of the search results. | |
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 | getSearchTypes () |
Return the search engines we support. | |
static | legalSearchChars ( $type=self::CHARS_ALL) |
Get chars legal for search NOTE: usage as static is deprecated and preserved only as BC measure. | |
static | namespacesAsText ( $namespaces) |
Get a list of namespace names useful for showing in tooltips and preferences. | |
static | parseNamespacePrefixes ( $query, $withAllKeyword=true, $withPrefixSearchExtractNamespaceHook=false) |
Parse some common prefixes: all (search everything) or namespace names. | |
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 | |
int[] null | $namespaces = [ NS_MAIN ] |
string | $prefix = '' |
const | CHARS_ALL = 1 |
@const int flag for legalSearchChars: includes all chars allowed in a search query | |
const | CHARS_NO_SYNTAX = 2 |
@const int flag for legalSearchChars: includes all chars allowed in a search term | |
const | COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
@const string profile type for completionSearch | |
const | DEFAULT_SORT = 'relevance' |
const | FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
@const string profile type for query independent ranking features | |
Protected Member Functions | |
completionSearchBackend ( $search) | |
Perform a completion search. | |
completionSearchBackendOverfetch ( $search) | |
Perform an overfetch of completion search results. | |
doSearchArchiveTitle ( $term) | |
Perform a title search in the article archive. | |
doSearchText ( $term) | |
Perform a full text search query and return a result set. | |
doSearchTitle ( $term) | |
Perform a title-only search query and return a result set. | |
normalizeNamespaces ( $search) | |
Makes search simple string if it was namespaced. | |
processCompletionResults ( $search, SearchSuggestionSet $suggestions) | |
Process completion search results. | |
simplePrefixSearch ( $search) | |
Call out to simple search backend. | |
Static Protected Member Functions | |
static | defaultNearMatcher () |
Get near matcher for default SearchEngine. | |
Protected Attributes | |
array | $features = [] |
Feature values. | |
int | $limit = 10 |
int | $offset = 0 |
array string | $searchTerms = [] |
bool | $showSuggestion = true |
Private Member Functions | |
maybePaginate (Closure $fn) | |
Performs an overfetch and shrink operation to determine if the next page is available for search engines that do not explicitly implement their own pagination. | |
Private Attributes | |
$sort = self::DEFAULT_SORT | |
Contain a class for special pages.
Definition at line 34 of file SearchEngine.php.
SearchEngine::augmentSearchResults | ( | SearchResultSet | $resultSet | ) |
Augment search results with extra data.
SearchResultSet | $resultSet |
Definition at line 886 of file SearchEngine.php.
References $data, $name, $rowAugmentors, and(), and SearchResultSet\setAugmentedData().
SearchEngine::completionSearch | ( | $search | ) |
Perform a completion search.
string | $search |
Definition at line 592 of file SearchEngine.php.
References and(), completionSearchBackendOverfetch(), SearchSuggestionSet\emptySuggestionSet(), normalizeNamespaces(), and processCompletionResults().
Referenced by completionSearchWithVariants(), SearchEnginePrefixTest\testPagination(), and SearchEnginePrefixTest\testSearchBackend().
|
protected |
Perform a completion search.
Does not resolve namespaces and does not check variants. Search engine implementations may want to override this function.
string | $search |
Reimplemented in MockCompletionSearchEngine.
Definition at line 567 of file SearchEngine.php.
References and(), SearchSuggestionSet\fromStrings(), SearchSuggestionSet\fromTitles(), namespaces, NS_SPECIAL, and simplePrefixSearch().
Referenced by completionSearchBackendOverfetch().
|
protected |
Perform an overfetch of completion search results.
This allows determining if another page of results is available.
string | $search |
Definition at line 551 of file SearchEngine.php.
References completionSearchBackend().
Referenced by completionSearch(), and completionSearchWithVariants().
SearchEngine::completionSearchWithVariants | ( | $search | ) |
Perform a completion search with variants.
string | $search |
Definition at line 606 of file SearchEngine.php.
References and(), completionSearch(), completionSearchBackendOverfetch(), SearchSuggestionSet\emptySuggestionSet(), normalizeNamespaces(), processCompletionResults(), and setLimitOffset().
|
static |
Load up the appropriate search engine class for the currently active database backend, and return a configured instance.
string | $type | Type of search backend, if not the default |
Definition at line 790 of file SearchEngine.php.
References $type, and wfDeprecated().
|
static |
An array of namespaces indexes to be searched by default.
Definition at line 764 of file SearchEngine.php.
References wfDeprecated().
|
staticprotected |
Get near matcher for default SearchEngine.
Definition at line 265 of file SearchEngine.php.
References $services.
SearchEngine::defaultPrefixSearch | ( | $search | ) |
Simple prefix search for subpages.
string | $search |
Definition at line 714 of file SearchEngine.php.
References and(), normalizeNamespaces(), and simplePrefixSearch().
SearchEngine::delete | ( | $id, | |
$title ) |
Delete an indexed page Title should be pre-processed.
STUB
Reimplemented in SearchMySQL.
Definition at line 500 of file SearchEngine.php.
|
protected |
Perform a title search in the article archive.
string | $term | Raw search term |
Definition at line 123 of file SearchEngine.php.
Referenced by searchArchiveTitle().
|
protected |
Perform a full text search query and return a result set.
string | $term | Raw search term |
Reimplemented in SearchDatabase, and MockSearchEngine.
Definition at line 94 of file SearchEngine.php.
Referenced by searchText().
|
protected |
Perform a title-only search query and return a result set.
string | $term | Raw search term |
Reimplemented in SearchDatabase.
Definition at line 151 of file SearchEngine.php.
Referenced by searchTitle().
SearchEngine::extractTitles | ( | SearchSuggestionSet | $completionResults | ) |
Extract titles from completion results.
SearchSuggestionSet | $completionResults |
Definition at line 637 of file SearchEngine.php.
SearchEngine::getFeatureData | ( | $feature | ) |
Way to retrieve custom data set by setFeatureData or by the engine itself.
string | $feature | feature name |
Definition at line 221 of file SearchEngine.php.
References and().
|
static |
If an exact title match can be found, or a very slightly close match, return the title.
If no match, returns NULL.
string | $searchterm |
Definition at line 278 of file SearchEngine.php.
References wfDeprecated().
SearchEngine::getNearMatcher | ( | Config | $config | ) |
Get service class to finding near matches.
Config | $config | Configuration to use for the matcher. |
Definition at line 256 of file SearchEngine.php.
Get a list of supported profiles.
Some search engine implementations may expose specific profiles to fine-tune its behaviors. The profile can be passed as a feature data with setFeatureData( $profileType, $profileName ) The array returned by this function contains the following keys:
string | $profileType | the type of profiles |
User | null | $user | the user requesting the list of profiles |
Definition at line 823 of file SearchEngine.php.
SearchEngine::getSearchIndexFields | ( | ) |
Get fields for search index.
Definition at line 844 of file SearchEngine.php.
|
static |
Return the search engines we support.
If only $wgSearchType is set, it'll be an array of just that one item.
Definition at line 802 of file SearchEngine.php.
References wfDeprecated().
SearchEngine::getSort | ( | ) |
Get the sort direction of the search results.
Definition at line 370 of file SearchEngine.php.
References $sort.
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.
Definition at line 514 of file SearchEngine.php.
SearchEngine::getValidSorts | ( | ) |
Get the valid sort directions.
All search engines support 'relevance' but others might support more. The default in all implementations must be 'relevance.'
Definition at line 344 of file SearchEngine.php.
Referenced by setSort().
|
static |
Get chars legal for search NOTE: usage as static is deprecated and preserved only as BC measure.
int | $type | type of search chars (see self::CHARS_ALL and self::CHARS_NO_SYNTAX). Defaults to CHARS_ALL |
Reimplemented in SearchMySQL, SearchOracle, and SearchSqlite.
Definition at line 291 of file SearchEngine.php.
Referenced by SearchDatabase\filter(), SearchUpdate\getNormalizedTitle(), and SearchMssql\parseQuery().
SearchEngine::makeSearchFieldMapping | ( | $name, | |
$type ) |
Create a search field definition.
Specific search engines should override this method to create search fields.
string | $name | |
int | $type | One of the types in SearchIndexField::INDEX_TYPE_* |
Definition at line 835 of file SearchEngine.php.
|
private |
Performs an overfetch and shrink operation to determine if the next page is available for search engines that do not explicitly implement their own pagination.
Closure | $fn | Takes no arguments |
Definition at line 163 of file SearchEngine.php.
References and(), and StatusValue\getValue().
Referenced by searchText(), and searchTitle().
|
static |
Get a list of namespace names useful for showing in tooltips and preferences.
array | $namespaces |
Definition at line 777 of file SearchEngine.php.
References $namespaces, and wfDeprecated().
|
protected |
Makes search simple string if it was namespaced.
Sets namespaces of the search to namespaces extracted from string.
string | $search |
Definition at line 535 of file SearchEngine.php.
References setNamespaces().
Referenced by completionSearch(), completionSearchWithVariants(), and defaultPrefixSearch().
SearchEngine::normalizeText | ( | $string | ) |
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).
string | $string | String to process |
Reimplemented in SearchMySQL.
Definition at line 233 of file SearchEngine.php.
Referenced by SearchUpdate\getNormalizedTitle().
|
static |
Parse some common prefixes: all (search everything) or namespace names.
string | $query | |
bool | $withAllKeyword | activate support of the "all:" keyword and its translations to activate searching on all namespaces. |
bool | $withPrefixSearchExtractNamespaceHook | call the PrefixSearchExtractNamespace hook if classic namespace identification did not match. |
FatalError | |
MWException |
Definition at line 402 of file SearchEngine.php.
References $query, and(), NS_MAIN, and wfMessage().
Referenced by SearchDatabase\extractNamespacePrefix().
|
protected |
Process completion search results.
Resolves the titles and rescores.
string | $search | |
SearchSuggestionSet | $suggestions |
Definition at line 650 of file SearchEngine.php.
References and(), SearchSuggestionSet\filter(), SearchSuggestion\fromTitle(), function, SearchSuggestionSet\map(), namespaces, SearchSuggestionSet\prepend(), SearchSuggestionSet\rescore(), and SearchSuggestionSet\shrink().
Referenced by completionSearch(), and completionSearchWithVariants().
SearchEngine::replacePrefixes | ( | $query | ) |
Parse some common prefixes: all (search everything) or namespace names and set the list of namespaces of this class accordingly.
string | $query |
Definition at line 383 of file SearchEngine.php.
References $query.
|
static |
Make a list of searchable namespaces and their canonical names.
Definition at line 740 of file SearchEngine.php.
References wfDeprecated().
SearchEngine::searchArchiveTitle | ( | $term | ) |
Perform a title search in the article archive.
NOTE: these results still should be filtered by matching against PageArchive, permissions checks etc The results returned by this methods are only sugegstions and may not end up being shown to the user.
As of 1.32 overriding this function is deprecated. It will be converted to final in 1.34. Override self::doSearchArchiveTitle().
string | $term | Raw search term |
Definition at line 112 of file SearchEngine.php.
References $term, and doSearchArchiveTitle().
SearchEngine::searchText | ( | $term | ) |
Perform a full text search query and return a result set.
If full text searches are not supported or disabled, return null.
As of 1.32 overriding this function is deprecated. It will be converted to final in 1.34. Override self::doSearchText().
string | $term | Raw search term |
Definition at line 81 of file SearchEngine.php.
References $term, doSearchText(), and maybePaginate().
SearchEngine::searchTitle | ( | $term | ) |
Perform a title-only search query and return a result set.
If title searches are not supported or disabled, return null. STUB
As of 1.32 overriding this function is deprecated. It will be converted to final in 1.34. Override self::doSearchTitle().
string | $term | Raw search term |
Definition at line 138 of file SearchEngine.php.
References $term, doSearchTitle(), and maybePaginate().
SearchEngine::setFeatureData | ( | $feature, | |
$data ) |
Way to pass custom data for engines.
string | $feature | |
mixed | $data |
Definition at line 210 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.
int | $limit | |
int | $offset |
Definition at line 302 of file SearchEngine.php.
References and().
Referenced by completionSearchWithVariants(), and SearchEnginePrefixTest\mockSearchWithResults().
SearchEngine::setNamespaces | ( | $namespaces | ) |
Set which namespaces the search should include.
Give an array of namespace index numbers.
int[] | null | $namespaces |
Definition at line 313 of file SearchEngine.php.
References $namespaces, and(), namespaces, and use.
Referenced by normalizeNamespaces().
SearchEngine::setShowSuggestion | ( | $showSuggestion | ) |
Set whether the searcher should try to build a suggestion.
Note: some searchers don't support building a suggestion in the first place and others don't respect this flag.
bool | $showSuggestion | Should the searcher try to build suggestions |
Definition at line 333 of file SearchEngine.php.
SearchEngine::setSort | ( | $sort | ) |
Set the sort direction of the search results.
Must be one returned by SearchEngine::getValidSorts()
InvalidArgumentException |
string | $sort | sort direction for query result |
Definition at line 356 of file SearchEngine.php.
References $sort, and(), and getValidSorts().
|
protected |
Call out to simple search backend.
Defaults to TitlePrefixSearch.
string | $search |
Definition at line 729 of file SearchEngine.php.
References PrefixSearch\defaultSearchBackend(), and namespaces.
Referenced by completionSearchBackend(), and defaultPrefixSearch().
SearchEngine::supports | ( | $feature | ) |
string | $feature |
Reimplemented in SearchMySQL.
Definition at line 194 of file SearchEngine.php.
SearchEngine::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.
Definition at line 525 of file SearchEngine.php.
SearchEngine::transformSearchTerm | ( | $term | ) |
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
string | $term |
Definition at line 247 of file SearchEngine.php.
References $term.
SearchEngine::update | ( | $id, | |
$title, | |||
$text ) |
Create or update the search index record for the given page.
Title and text should be pre-processed. STUB
int | $id | |
string | $title | |
string | $text |
Reimplemented in SearchMssql, SearchMySQL, SearchOracle, SearchSqlite, MockSearch, and SearchPostgres.
Definition at line 476 of file SearchEngine.php.
SearchEngine::updateTitle | ( | $id, | |
$title ) |
Update a search index record's title only.
Title should be pre-processed. STUB
int | $id | |
string | $title |
Reimplemented in SearchMssql, SearchMySQL, SearchOracle, SearchPostgres, and SearchSqlite.
Definition at line 488 of file SearchEngine.php.
|
static |
Find snippet highlight settings for all users.
Definition at line 461 of file SearchEngine.php.
References and().
|
static |
Extract default namespaces to search from the given user's settings, returning a list of index numbers.
user | $user |
Definition at line 753 of file SearchEngine.php.
References wfDeprecated().
|
protected |
Feature values.
Definition at line 57 of file SearchEngine.php.
|
protected |
Definition at line 44 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult().
Definition at line 41 of file SearchEngine.php.
Referenced by SearchMySQL\queryNamespaces(), SearchMssql\queryNamespaces(), SearchOracle\queryNamespaces(), SearchSqlite\queryNamespaces(), and SearchPostgres\searchQuery().
|
protected |
Definition at line 47 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult().
string SearchEngine::$prefix = '' |
Definition at line 38 of file SearchEngine.php.
|
protected |
Definition at line 50 of file SearchEngine.php.
|
protected |
Definition at line 53 of file SearchEngine.php.
|
private |
Definition at line 54 of file SearchEngine.php.
const SearchEngine::CHARS_ALL = 1 |
@const int flag for legalSearchChars: includes all chars allowed in a search query
Definition at line 66 of file SearchEngine.php.
const SearchEngine::CHARS_NO_SYNTAX = 2 |
@const int flag for legalSearchChars: includes all chars allowed in a search term
Definition at line 69 of file SearchEngine.php.
const SearchEngine::COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
@const string profile type for completionSearch
Definition at line 60 of file SearchEngine.php.
const SearchEngine::DEFAULT_SORT = 'relevance' |
Definition at line 35 of file SearchEngine.php.
const SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
@const string profile type for query independent ranking features
Definition at line 63 of file SearchEngine.php.