MediaWiki fundraising/REL1_35
|
Contain a class for special pages Stable to extend. More...
Public Member Functions | |
augmentSearchResults (ISearchResultSet $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. | |
legalSearchChars ( $type=self::CHARS_ALL) | |
Get chars legal for search. | |
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. | |
setHookContainer (HookContainer $hookContainer) | |
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. | |
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 | parseNamespacePrefixes ( $query, $withAllKeyword=true, $withPrefixSearchExtractNamespaceHook=false) |
Parse some common prefixes: all (search everything) or namespace names. | |
static | userHighlightPrefs () |
Find snippet highlight settings for all users. | |
Public Attributes | |
int[] null | $namespaces = [ NS_MAIN ] |
string | $prefix = '' |
const | COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
Profile type for completionSearch. | |
const | DEFAULT_SORT = 'relevance' |
const | FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
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. | |
getHookContainer () | |
Get a HookContainer, for running extension hooks or for hook metadata. | |
getHookRunner () | |
Get a HookRunner for running core hooks. | |
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 |
string[] | $searchTerms = [] |
bool | $showSuggestion = true |
const | CHARS_ALL = 1 |
Integer flag for legalSearchChars: includes all chars allowed in a search query. | |
const | CHARS_NO_SYNTAX = 2 |
Integer flag for legalSearchChars: includes all chars allowed in a search term. | |
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 | |
HookContainer | $hookContainer |
HookRunner | $hookRunner |
$sort = self::DEFAULT_SORT | |
Contain a class for special pages Stable to extend.
Definition at line 37 of file SearchEngine.php.
SearchEngine::augmentSearchResults | ( | ISearchResultSet | $resultSet | ) |
Augment search results with extra data.
ISearchResultSet | $resultSet |
Definition at line 827 of file SearchEngine.php.
References getHookRunner(), and ISearchResultSet\setAugmentedData().
SearchEngine::completionSearch | ( | $search | ) |
Perform a completion search.
string | $search |
Definition at line 597 of file SearchEngine.php.
References completionSearchBackendOverfetch(), SearchSuggestionSet\emptySuggestionSet(), normalizeNamespaces(), and processCompletionResults().
Referenced by completionSearchWithVariants().
|
protected |
Perform a completion search.
Does not resolve namespaces and does not check variants. Search engine implementations may want to override this function.
Stable to override
string | $search |
Definition at line 572 of file SearchEngine.php.
References SearchSuggestionSet\fromStrings(), SearchSuggestionSet\fromTitles(), getHookRunner(), 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 553 of file SearchEngine.php.
References completionSearchBackend().
Referenced by completionSearch(), and completionSearchWithVariants().
SearchEngine::completionSearchWithVariants | ( | $search | ) |
Perform a completion search with variants.
Stable to override
string | $search |
Definition at line 613 of file SearchEngine.php.
References completionSearch(), completionSearchBackendOverfetch(), SearchSuggestionSet\emptySuggestionSet(), normalizeNamespaces(), processCompletionResults(), and setLimitOffset().
|
staticprotected |
Get near matcher for default SearchEngine.
Definition at line 274 of file SearchEngine.php.
SearchEngine::defaultPrefixSearch | ( | $search | ) |
Simple prefix search for subpages.
string | $search |
Definition at line 721 of file SearchEngine.php.
References 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.
Stable to override
string | $term | Raw search term |
Definition at line 139 of file SearchEngine.php.
Referenced by searchArchiveTitle().
|
protected |
Perform a full text search query and return a result set.
Stable to override
string | $term | Raw search term |
Reimplemented in SearchDatabase.
Definition at line 108 of file SearchEngine.php.
Referenced by searchText().
|
protected |
Perform a title-only search query and return a result set.
Stable to override
string | $term | Raw search term |
Reimplemented in SearchDatabase.
Definition at line 169 of file SearchEngine.php.
Referenced by searchTitle().
SearchEngine::extractTitles | ( | SearchSuggestionSet | $completionResults | ) |
Extract titles from completion results.
SearchSuggestionSet | $completionResults |
Definition at line 644 of file SearchEngine.php.
References SearchSuggestion\getSuggestedTitle(), and SearchSuggestionSet\map().
SearchEngine::getFeatureData | ( | $feature | ) |
Way to retrieve custom data set by setFeatureData or by the engine itself.
string | $feature | feature name |
Definition at line 241 of file SearchEngine.php.
|
protected |
Get a HookContainer, for running extension hooks or for hook metadata.
Definition at line 872 of file SearchEngine.php.
Referenced by getNearMatcher().
|
protected |
Get a HookRunner for running core hooks.
Definition at line 887 of file SearchEngine.php.
Referenced by augmentSearchResults(), completionSearchBackend(), and getSearchIndexFields().
SearchEngine::getNearMatcher | ( | Config | $config | ) |
Get service class to finding near matches.
Config | $config | Configuration to use for the matcher. |
Definition at line 263 of file SearchEngine.php.
References getHookContainer().
SearchEngine::getProfiles | ( | $profileType, | |
User | $user = null ) |
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 760 of file SearchEngine.php.
SearchEngine::getSearchIndexFields | ( | ) |
Get fields for search index.
Definition at line 783 of file SearchEngine.php.
References getHookRunner().
SearchEngine::getSort | ( | ) |
Get the sort direction of the search results.
Definition at line 367 of file SearchEngine.php.
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 515 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 341 of file SearchEngine.php.
Referenced by setSort().
SearchEngine::legalSearchChars | ( | $type = self::CHARS_ALL | ) |
Get chars legal for search.
int | $type | type of search chars (see self::CHARS_ALL and self::CHARS_NO_SYNTAX). Defaults to CHARS_ALL |
Reimplemented in SearchMySQL, and SearchSqlite.
Definition at line 286 of file SearchEngine.php.
Referenced by SearchDatabase\filter(), and SearchUpdate\getNormalizedTitle().
SearchEngine::makeSearchFieldMapping | ( | $name, | |
$type ) |
Create a search field definition.
Specific search engines should override this method to create search fields. Stable to override
string | $name | |
string | $type | One of the types in SearchIndexField::INDEX_TYPE_* |
Definition at line 774 of file SearchEngine.php.
Referenced by ContentHandler\addSearchField(), ContentHandler\getFieldsForSearchIndex(), FileContentHandler\getFieldsForSearchIndex(), TextContentHandler\getFieldsForSearchIndex(), and WikitextContentHandler\getFieldsForSearchIndex().
|
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 181 of file SearchEngine.php.
References StatusValue\getValue().
Referenced by searchText(), and searchTitle().
|
protected |
Makes search simple string if it was namespaced.
Sets namespaces of the search to namespaces extracted from string.
string | $search |
Definition at line 537 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 253 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 399 of file SearchEngine.php.
References 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 657 of file SearchEngine.php.
References SearchSuggestionSet\filter(), SearchSuggestion\getSuggestedTitle(), SearchSuggestionSet\map(), 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 380 of file SearchEngine.php.
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.
string | $term | Raw search term |
Definition at line 126 of file SearchEngine.php.
References 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.
string | $term | Raw search term |
Definition at line 93 of file SearchEngine.php.
References 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
string | $term | Raw search term |
Definition at line 154 of file SearchEngine.php.
References doSearchTitle(), and maybePaginate().
SearchEngine::setFeatureData | ( | $feature, | |
$data ) |
Way to pass custom data for engines.
string | $feature | |
mixed | $data |
Definition at line 230 of file SearchEngine.php.
SearchEngine::setHookContainer | ( | HookContainer | $hookContainer | ) |
Definition at line 861 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 297 of file SearchEngine.php.
Referenced by completionSearchWithVariants().
SearchEngine::setNamespaces | ( | $namespaces | ) |
Set which namespaces the search should include.
Give an array of namespace index numbers.
int[] | null | $namespaces |
Definition at line 308 of file SearchEngine.php.
References $namespaces.
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 328 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 353 of file SearchEngine.php.
References $sort, and getValidSorts().
|
protected |
Call out to simple search backend.
Defaults to TitlePrefixSearch.
string | $search |
Definition at line 736 of file SearchEngine.php.
References PrefixSearch\defaultSearchBackend().
Referenced by completionSearchBackend(), and defaultPrefixSearch().
SearchEngine::supports | ( | $feature | ) |
string | $feature |
Reimplemented in SearchMySQL.
Definition at line 214 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 527 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
int | $id | |
string | $title | |
string | $text |
Reimplemented in SearchMySQL, SearchSqlite, 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 SearchMySQL, 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 SearchHighlighter\DEFAULT_CONTEXT_CHARS, and SearchHighlighter\DEFAULT_CONTEXT_LINES.
|
protected |
Feature values.
Definition at line 63 of file SearchEngine.php.
|
private |
Definition at line 66 of file SearchEngine.php.
|
private |
Definition at line 69 of file SearchEngine.php.
|
protected |
Definition at line 47 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult().
int [] null SearchEngine::$namespaces = [ NS_MAIN ] |
Definition at line 44 of file SearchEngine.php.
Referenced by SearchMySQL\queryNamespaces(), SearchSqlite\queryNamespaces(), SearchPostgres\searchQuery(), and setNamespaces().
|
protected |
Definition at line 50 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult().
string SearchEngine::$prefix = '' |
Definition at line 41 of file SearchEngine.php.
|
protected |
Definition at line 56 of file SearchEngine.php.
|
protected |
Definition at line 59 of file SearchEngine.php.
|
private |
Definition at line 60 of file SearchEngine.php.
Referenced by setSort().
|
protected |
Integer flag for legalSearchChars: includes all chars allowed in a search query.
Definition at line 78 of file SearchEngine.php.
|
protected |
Integer flag for legalSearchChars: includes all chars allowed in a search term.
Definition at line 81 of file SearchEngine.php.
const SearchEngine::COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
Profile type for completionSearch.
Definition at line 72 of file SearchEngine.php.
const SearchEngine::DEFAULT_SORT = 'relevance' |
Definition at line 38 of file SearchEngine.php.
const SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
Profile type for query independent ranking features.
Definition at line 75 of file SearchEngine.php.