MediaWiki
master
|
Contain a class for special pages. More...
Public Member Functions | |
augmentSearchResults (ISearchResultSet $resultSet) | |
Augment search results with extra data. More... | |
completionSearch ( $search) | |
Perform a completion search. More... | |
completionSearchWithVariants ( $search) | |
Perform a completion search with variants. More... | |
defaultPrefixSearch ( $search) | |
Simple prefix search for subpages. More... | |
delete ( $id, $title) | |
Delete an indexed page Title should be pre-processed. More... | |
extractTitles (SearchSuggestionSet $completionResults) | |
Extract titles from completion results. More... | |
getFeatureData ( $feature) | |
Way to retrieve custom data set by setFeatureData or by the engine itself. More... | |
getNearMatcher (Config $config) | |
Get service class to finding near matches. More... | |
getProfiles ( $profileType, User $user=null) | |
Get a list of supported profiles. More... | |
getSearchIndexFields () | |
Get fields for search index. More... | |
getSort () | |
Get the sort direction of the search results. More... | |
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. More... | |
getValidSorts () | |
Get the valid sort directions. More... | |
legalSearchChars ( $type=self::CHARS_ALL) | |
Get chars legal for search. More... | |
makeSearchFieldMapping ( $name, $type) | |
Create a search field definition. More... | |
normalizeText ( $string) | |
When overridden in derived class, performs database-specific conversions on text to be used for searching or updating search index. More... | |
replacePrefixes ( $query) | |
Parse some common prefixes: all (search everything) or namespace names and set the list of namespaces of this class accordingly. More... | |
searchArchiveTitle ( $term) | |
Perform a title search in the article archive. More... | |
searchText ( $term) | |
Perform a full text search query and return a result set. More... | |
searchTitle ( $term) | |
Perform a title-only search query and return a result set. More... | |
setFeatureData ( $feature, $data) | |
Way to pass custom data for engines. More... | |
setHookContainer (HookContainer $hookContainer) | |
setLimitOffset ( $limit, $offset=0) | |
Set the maximum number of results to return and how many to skip before returning the first. More... | |
setNamespaces ( $namespaces) | |
Set which namespaces the search should include. More... | |
setShowSuggestion ( $showSuggestion) | |
Set whether the searcher should try to build a suggestion. More... | |
setSort ( $sort) | |
Set the sort direction of the search results. More... | |
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. More... | |
update ( $id, $title, $text) | |
Create or update the search index record for the given page. More... | |
updateTitle ( $id, $title) | |
Update a search index record's title only. More... | |
Static Public Member Functions | |
static | parseNamespacePrefixes ( $query, $withAllKeyword=true, $withPrefixSearchExtractNamespaceHook=false) |
Parse some common prefixes: all (search everything) or namespace names. More... | |
static | userHighlightPrefs () |
Find snippet highlight settings for all users. More... | |
Public Attributes | |
int[] null | $namespaces = [ NS_MAIN ] |
string | $prefix = '' |
const | COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
Profile type for completionSearch. More... | |
const | DEFAULT_SORT = 'relevance' |
const | FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
Profile type for query independent ranking features. More... | |
Protected Member Functions | |
completionSearchBackend ( $search) | |
Perform a completion search. More... | |
completionSearchBackendOverfetch ( $search) | |
Perform an overfetch of completion search results. More... | |
doSearchArchiveTitle ( $term) | |
Perform a title search in the article archive. More... | |
doSearchText ( $term) | |
Perform a full text search query and return a result set. More... | |
doSearchTitle ( $term) | |
Perform a title-only search query and return a result set. More... | |
getHookContainer () | |
Get a HookContainer, for running extension hooks or for hook metadata. More... | |
getHookRunner () | |
Get a HookRunner for running core hooks. More... | |
normalizeNamespaces ( $search) | |
Makes search simple string if it was namespaced. More... | |
processCompletionResults ( $search, SearchSuggestionSet $suggestions) | |
Process completion search results. More... | |
simplePrefixSearch ( $search) | |
Call out to simple search backend. More... | |
Static Protected Member Functions | |
static | defaultNearMatcher () |
Get near matcher for default SearchEngine. More... | |
Protected Attributes | |
array | $features = [] |
Feature values. More... | |
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. More... | |
const | CHARS_NO_SYNTAX = 2 |
Integer flag for legalSearchChars: includes all chars allowed in a search term. More... | |
Contain a class for special pages.
Definition at line 39 of file SearchEngine.php.
SearchEngine::augmentSearchResults | ( | ISearchResultSet | $resultSet | ) |
Augment search results with extra data.
ISearchResultSet | $resultSet |
Definition at line 831 of file SearchEngine.php.
References getHookRunner(), and ISearchResultSet\setAugmentedData().
SearchEngine::completionSearch | ( | $search | ) |
Perform a completion search.
string | $search |
Definition at line 599 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.
string | $search |
Definition at line 574 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 555 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 615 of file SearchEngine.php.
References completionSearch(), completionSearchBackendOverfetch(), SearchSuggestionSet\emptySuggestionSet(), normalizeNamespaces(), processCompletionResults(), and setLimitOffset().
|
staticprotected |
Get near matcher for default SearchEngine.
Definition at line 276 of file SearchEngine.php.
References wfDeprecated().
SearchEngine::defaultPrefixSearch | ( | $search | ) |
Simple prefix search for subpages.
string | $search |
Definition at line 726 of file SearchEngine.php.
References normalizeNamespaces(), and simplePrefixSearch().
SearchEngine::delete | ( | $id, | |
$title | |||
) |
Delete an indexed page Title should be pre-processed.
STUB
int | $id | Page id that was deleted |
string | $title | Title of page that was deleted |
Reimplemented in SearchMySQL.
Definition at line 502 of file SearchEngine.php.
|
protected |
Perform a title search in the article archive.
string | $term | Raw search term |
Definition at line 141 of file SearchEngine.php.
References StatusValue\newGood().
Referenced by searchArchiveTitle().
|
protected |
Perform a full text search query and return a result set.
string | $term | Raw search term |
Reimplemented in SearchDatabase.
Definition at line 110 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 171 of file SearchEngine.php.
Referenced by searchTitle().
SearchEngine::extractTitles | ( | SearchSuggestionSet | $completionResults | ) |
Extract titles from completion results.
SearchSuggestionSet | $completionResults |
Definition at line 648 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 243 of file SearchEngine.php.
|
protected |
Get a HookContainer, for running extension hooks or for hook metadata.
Definition at line 876 of file SearchEngine.php.
|
protected |
Get a HookRunner for running core hooks.
Definition at line 894 of file SearchEngine.php.
Referenced by augmentSearchResults(), completionSearchBackend(), and getSearchIndexFields().
SearchEngine::getNearMatcher | ( | Config | $config | ) |
Get service class to finding near matches.
Definition at line 266 of file SearchEngine.php.
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 765 of file SearchEngine.php.
SearchEngine::getSearchIndexFields | ( | ) |
Get fields for search index.
Definition at line 788 of file SearchEngine.php.
References getHookRunner().
SearchEngine::getSort | ( | ) |
Get the sort direction of the search results.
Definition at line 368 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 517 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 342 of file SearchEngine.php.
References DEFAULT_SORT.
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 SearchSqlite, and SearchMySQL.
Definition at line 287 of file SearchEngine.php.
Referenced by SearchDatabase\filter().
SearchEngine::makeSearchFieldMapping | ( | $name, | |
$type | |||
) |
Create a search field definition.
Specific search engines should override this method to create search fields.
string | $name | |
string | $type | One of the types in SearchIndexField::INDEX_TYPE_* |
Definition at line 779 of file SearchEngine.php.
Referenced by ContentHandler\addSearchField(), ContentHandler\getFieldsForSearchIndex(), FileContentHandler\getFieldsForSearchIndex(), TextContentHandler\getFieldsForSearchIndex(), and WikitextContentHandler\getFieldsForSearchIndex().
|
protected |
Makes search simple string if it was namespaced.
Sets namespaces of the search to namespaces extracted from string.
string | $search |
Definition at line 539 of file SearchEngine.php.
References parseNamespacePrefixes(), and 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 255 of file SearchEngine.php.
|
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 400 of file SearchEngine.php.
References $prefix, NS_MAIN, and wfMessage().
Referenced by SearchDatabase\extractNamespacePrefix(), normalizeNamespaces(), and PrefixSearch\search().
|
protected |
Process completion search results.
Resolves the titles and rescores.
string | $search | |
SearchSuggestionSet | $suggestions |
Definition at line 661 of file SearchEngine.php.
References SearchSuggestionSet\filter(), SearchSuggestion\fromTitle(), 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 381 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 suggestions and may not end up being shown to the user.
string | $term | Raw search term |
Definition at line 128 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 95 of file SearchEngine.php.
References doSearchText().
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 156 of file SearchEngine.php.
References doSearchTitle().
SearchEngine::setFeatureData | ( | $feature, | |
$data | |||
) |
Way to pass custom data for engines.
string | $feature | |
mixed | $data |
Definition at line 232 of file SearchEngine.php.
SearchEngine::setHookContainer | ( | HookContainer | $hookContainer | ) |
HookContainer | $hookContainer |
Definition at line 865 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 298 of file SearchEngine.php.
References $limit, and $offset.
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 309 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 329 of file SearchEngine.php.
References $showSuggestion.
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 354 of file SearchEngine.php.
References getValidSorts().
|
protected |
Call out to simple search backend.
Defaults to TitlePrefixSearch.
string | $search |
Definition at line 741 of file SearchEngine.php.
References PrefixSearch\defaultSearchBackend().
Referenced by completionSearchBackend(), and defaultPrefixSearch().
SearchEngine::supports | ( | $feature | ) |
string | $feature |
Reimplemented in SearchMySQL.
Definition at line 216 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 529 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 SearchPostgres, SearchSqlite, and SearchMySQL.
Definition at line 478 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 SearchSqlite, SearchPostgres, and SearchMySQL.
Definition at line 490 of file SearchEngine.php.
|
static |
Find snippet highlight settings for all users.
Definition at line 463 of file SearchEngine.php.
References SearchHighlighter\DEFAULT_CONTEXT_CHARS, and SearchHighlighter\DEFAULT_CONTEXT_LINES.
|
protected |
Feature values.
Definition at line 65 of file SearchEngine.php.
|
protected |
Definition at line 49 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult(), and setLimitOffset().
int [] null SearchEngine::$namespaces = [ NS_MAIN ] |
Definition at line 46 of file SearchEngine.php.
Referenced by setNamespaces().
|
protected |
Definition at line 52 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult(), and setLimitOffset().
string SearchEngine::$prefix = '' |
Definition at line 43 of file SearchEngine.php.
Referenced by parseNamespacePrefixes().
|
protected |
Definition at line 58 of file SearchEngine.php.
|
protected |
Definition at line 61 of file SearchEngine.php.
Referenced by setShowSuggestion().
|
protected |
Integer flag for legalSearchChars: includes all chars allowed in a search query.
Definition at line 80 of file SearchEngine.php.
|
protected |
Integer flag for legalSearchChars: includes all chars allowed in a search term.
Definition at line 83 of file SearchEngine.php.
const SearchEngine::COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
Profile type for completionSearch.
Definition at line 74 of file SearchEngine.php.
Referenced by ApiOpenSearch\getSearchProfileParams(), and ApiQueryPrefixSearch\getSearchProfileParams().
const SearchEngine::DEFAULT_SORT = 'relevance' |
Definition at line 40 of file SearchEngine.php.
Referenced by ApiQuerySearch\getAllowedParams(), getValidSorts(), and SpecialSearch\load().
const SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
Profile type for query independent ranking features.
Definition at line 77 of file SearchEngine.php.
Referenced by ApiQuerySearch\getSearchProfileParams().