|
MediaWiki master
|
Contain a class for special pages. More...
Inherited by MediaWiki\Search\SearchDatabase, and MediaWiki\Search\SearchEngineDummy.
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. | |
| 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. | |
| 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) | |
| 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_DEP_PROFILE_TYPE = 'fulltextQueryDepProfile' |
| Profile type for query dependent ranking features (ex: field weights) | |
| const | FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
| Profile type for query independent ranking features (ex: article popularity) | |
| const | SEARCH_ID = 'searchId' |
| Name of the feature data entry holding an identifier generated by some search backends. | |
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. | |
Contain a class for special pages.
Definition at line 33 of file SearchEngine.php.
| MediaWiki\Search\SearchEngine::augmentSearchResults | ( | ISearchResultSet | $resultSet | ) |
Augment search results with extra data.
Definition at line 794 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\getHookRunner(), and MediaWiki\Search\ISearchResultSet\setAugmentedData().
| MediaWiki\Search\SearchEngine::completionSearch | ( | $search | ) |
Perform a completion search.
| string | $search |
Definition at line 547 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\completionSearchBackendOverfetch(), MediaWiki\Search\SearchSuggestionSet\emptySuggestionSet(), MediaWiki\Search\SearchEngine\normalizeNamespaces(), and MediaWiki\Search\SearchEngine\processCompletionResults().
Referenced by MediaWiki\Search\SearchEngine\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 536 of file SearchEngine.php.
References MediaWiki\Search\SearchSuggestionSet\fromTitles(), and MediaWiki\Search\SearchEngine\simplePrefixSearch().
Referenced by MediaWiki\Search\SearchEngine\completionSearchBackendOverfetch().
|
protected |
Perform an overfetch of completion search results.
This allows determining if another page of results is available.
| string | $search |
Definition at line 517 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\completionSearchBackend().
Referenced by MediaWiki\Search\SearchEngine\completionSearch(), and MediaWiki\Search\SearchEngine\completionSearchWithVariants().
| MediaWiki\Search\SearchEngine::completionSearchWithVariants | ( | $search | ) |
Perform a completion search with variants.
| string | $search |
Definition at line 563 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\$limit, MediaWiki\Search\SearchEngine\$offset, MediaWiki\Search\SearchEngine\completionSearch(), MediaWiki\Search\SearchEngine\completionSearchBackendOverfetch(), MediaWiki\Search\SearchSuggestionSet\emptySuggestionSet(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Search\SearchEngine\normalizeNamespaces(), MediaWiki\Search\SearchEngine\processCompletionResults(), and MediaWiki\Search\SearchEngine\setLimitOffset().
|
staticprotected |
Get near matcher for default SearchEngine.
Definition at line 281 of file SearchEngine.php.
References MediaWiki\MediaWikiServices\getInstance(), and wfDeprecated().
| MediaWiki\Search\SearchEngine::defaultPrefixSearch | ( | $search | ) |
Simple prefix search for subpages.
| string | $search |
Definition at line 691 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\normalizeNamespaces(), and MediaWiki\Search\SearchEngine\simplePrefixSearch().
| MediaWiki\Search\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 MediaWiki\Search\SearchMySQL.
Definition at line 491 of file SearchEngine.php.
|
protected |
Perform a title search in the article archive.
| string | $term | Raw search term |
Definition at line 146 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\searchArchiveTitle().
|
protected |
Perform a full text search query and return a result set.
| string | $term | Raw search term |
Reimplemented in MediaWiki\Search\SearchDatabase.
Definition at line 115 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\searchText().
|
protected |
Perform a title-only search query and return a result set.
| string | $term | Raw search term |
Reimplemented in MediaWiki\Search\SearchDatabase.
Definition at line 176 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\searchTitle().
| MediaWiki\Search\SearchEngine::extractTitles | ( | SearchSuggestionSet | $completionResults | ) |
Extract titles from completion results.
| SearchSuggestionSet | $completionResults |
Definition at line 602 of file SearchEngine.php.
References MediaWiki\Search\SearchSuggestion\getSuggestedTitle(), and MediaWiki\Search\SearchSuggestionSet\map().
| MediaWiki\Search\SearchEngine::getFeatureData | ( | $feature | ) |
Way to retrieve custom data set by setFeatureData or by the engine itself.
| string | $feature | feature name |
Definition at line 248 of file SearchEngine.php.
|
protected |
Get a HookContainer, for running extension hooks or for hook metadata.
Definition at line 839 of file SearchEngine.php.
References MediaWiki\MediaWikiServices\getInstance().
|
protected |
Get a HookRunner for running core hooks.
Definition at line 857 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\augmentSearchResults(), and MediaWiki\Search\SearchEngine\getSearchIndexFields().
| MediaWiki\Search\SearchEngine::getNearMatcher | ( | Config | $config | ) |
Get service class to finding near matches.
Definition at line 271 of file SearchEngine.php.
References MediaWiki\MediaWikiServices\getInstance().
| MediaWiki\Search\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 730 of file SearchEngine.php.
| MediaWiki\Search\SearchEngine::getSearchIndexFields | ( | ) |
Get fields for search index.
Definition at line 753 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\getHookRunner(), and MediaWiki\MediaWikiServices\getInstance().
| MediaWiki\Search\SearchEngine::getSort | ( | ) |
Get the sort direction of the search results.
Definition at line 372 of file SearchEngine.php.
| MediaWiki\Search\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 347 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\DEFAULT_SORT.
Referenced by MediaWiki\Search\SearchEngine\setSort().
| MediaWiki\Search\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 MediaWiki\Search\SearchMySQL, and MediaWiki\Search\SearchSqlite.
Definition at line 292 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchDatabase\filter().
| MediaWiki\Search\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 744 of file SearchEngine.php.
Referenced by MediaWiki\Content\ContentHandler\addSearchField(), MediaWiki\Content\ContentHandler\getFieldsForSearchIndex(), MediaWiki\Content\FileContentHandler\getFieldsForSearchIndex(), MediaWiki\Content\TextContentHandler\getFieldsForSearchIndex(), and MediaWiki\Content\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 501 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\parseNamespacePrefixes(), and MediaWiki\Search\SearchEngine\setNamespaces().
Referenced by MediaWiki\Search\SearchEngine\completionSearch(), MediaWiki\Search\SearchEngine\completionSearchWithVariants(), and MediaWiki\Search\SearchEngine\defaultPrefixSearch().
| MediaWiki\Search\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 MediaWiki\Search\SearchMySQL.
Definition at line 260 of file SearchEngine.php.
References MediaWiki\MediaWikiServices\getInstance().
|
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. |
Definition at line 389 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\$prefix, MediaWiki\MediaWikiServices\getInstance(), NS_MAIN, and wfMessage().
Referenced by MediaWiki\Search\SearchDatabase\extractNamespacePrefix(), MediaWiki\Search\SearchEngine\normalizeNamespaces(), and MediaWiki\Search\PrefixSearch\search().
|
protected |
Process completion search results.
Resolves the titles and rescores.
| string | $search | |
| SearchSuggestionSet | $suggestions |
Definition at line 615 of file SearchEngine.php.
References MediaWiki\Search\SearchSuggestionSet\filter(), MediaWiki\Search\SearchSuggestion\fromTitle(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Search\SearchSuggestion\getSuggestedTitle(), MediaWiki\Search\SearchSuggestionSet\map(), MediaWiki\Search\SearchSuggestionSet\prepend(), MediaWiki\Search\SearchSuggestionSet\remove(), MediaWiki\Search\SearchSuggestionSet\rescore(), and MediaWiki\Search\SearchSuggestionSet\shrink().
Referenced by MediaWiki\Search\SearchEngine\completionSearch(), and MediaWiki\Search\SearchEngine\completionSearchWithVariants().
| MediaWiki\Search\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 133 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\doSearchArchiveTitle().
| MediaWiki\Search\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 100 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\doSearchText().
| MediaWiki\Search\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 161 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\doSearchTitle().
| MediaWiki\Search\SearchEngine::setFeatureData | ( | $feature, | |
| $data ) |
Way to pass custom data for engines.
| string | $feature | |
| mixed | $data |
Definition at line 237 of file SearchEngine.php.
| MediaWiki\Search\SearchEngine::setHookContainer | ( | HookContainer | $hookContainer | ) |
| HookContainer | $hookContainer |
Definition at line 828 of file SearchEngine.php.
| MediaWiki\Search\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 303 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\$limit, and MediaWiki\Search\SearchEngine\$offset.
Referenced by MediaWiki\Search\SearchEngine\completionSearchWithVariants().
| MediaWiki\Search\SearchEngine::setNamespaces | ( | $namespaces | ) |
Set which namespaces the search should include.
Give an array of namespace index numbers.
| int[] | null | $namespaces |
Definition at line 314 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\$namespaces, and MediaWiki\MediaWikiServices\getInstance().
Referenced by MediaWiki\Search\SearchEngine\normalizeNamespaces().
| MediaWiki\Search\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 334 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\$showSuggestion.
| MediaWiki\Search\SearchEngine::setSort | ( | $sort | ) |
Set the sort direction of the search results.
Must be one returned by SearchEngine::getValidSorts()
| string | $sort | sort direction for query result |
Definition at line 358 of file SearchEngine.php.
References MediaWiki\Search\SearchEngine\getValidSorts().
|
protected |
Call out to simple search backend.
Defaults to TitlePrefixSearch.
| string | $search |
Definition at line 706 of file SearchEngine.php.
References MediaWiki\Search\PrefixSearch\defaultSearchBackend().
Referenced by MediaWiki\Search\SearchEngine\completionSearchBackend(), and MediaWiki\Search\SearchEngine\defaultPrefixSearch().
| MediaWiki\Search\SearchEngine::supports | ( | $feature | ) |
| string | $feature |
Reimplemented in MediaWiki\Search\SearchMySQL.
Definition at line 221 of file SearchEngine.php.
| MediaWiki\Search\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 MediaWiki\Search\SearchMySQL, MediaWiki\Search\SearchSqlite, and MediaWiki\Search\SearchPostgres.
Definition at line 467 of file SearchEngine.php.
| MediaWiki\Search\SearchEngine::updateTitle | ( | $id, | |
| $title ) |
Update a search index record's title only.
Title should be pre-processed. STUB
| int | $id | |
| string | $title |
Reimplemented in MediaWiki\Search\SearchMySQL, MediaWiki\Search\SearchPostgres, and MediaWiki\Search\SearchSqlite.
Definition at line 479 of file SearchEngine.php.
|
static |
Find snippet highlight settings for all users.
Definition at line 452 of file SearchEngine.php.
References MediaWiki\Search\SearchHighlighter\DEFAULT_CONTEXT_CHARS, and MediaWiki\Search\SearchHighlighter\DEFAULT_CONTEXT_LINES.
|
protected |
Feature values.
Definition at line 60 of file SearchEngine.php.
|
protected |
Definition at line 43 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\completionSearchWithVariants(), and MediaWiki\Search\SearchEngine\setLimitOffset().
| int [] null MediaWiki\Search\SearchEngine::$namespaces = [ NS_MAIN ] |
Definition at line 40 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\setNamespaces().
|
protected |
Definition at line 46 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\completionSearchWithVariants(), and MediaWiki\Search\SearchEngine\setLimitOffset().
| string MediaWiki\Search\SearchEngine::$prefix = '' |
Definition at line 37 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\parseNamespacePrefixes().
|
protected |
Definition at line 52 of file SearchEngine.php.
|
protected |
Definition at line 55 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\setShowSuggestion().
|
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 MediaWiki\Search\SearchEngine::COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
Profile type for completionSearch.
Definition at line 69 of file SearchEngine.php.
| const MediaWiki\Search\SearchEngine::DEFAULT_SORT = 'relevance' |
Definition at line 34 of file SearchEngine.php.
Referenced by MediaWiki\Search\SearchEngine\getValidSorts().
| const MediaWiki\Search\SearchEngine::FT_QUERY_DEP_PROFILE_TYPE = 'fulltextQueryDepProfile' |
Profile type for query dependent ranking features (ex: field weights)
Definition at line 75 of file SearchEngine.php.
| const MediaWiki\Search\SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
Profile type for query independent ranking features (ex: article popularity)
Definition at line 72 of file SearchEngine.php.
| const MediaWiki\Search\SearchEngine::SEARCH_ID = 'searchId' |
Name of the feature data entry holding an identifier generated by some search backends.
This may be used by some endpoint to propagate it via the X-Search-ID header for analytics/debugging purposes.
Definition at line 88 of file SearchEngine.php.