MediaWiki
1.28.0
|
Contain a class for special pages. More...
Public Member Functions | |
augmentSearchResults (SearchResultSet $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... | |
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... | |
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... | |
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... | |
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... | |
transformSearchTerm ($term) | |
Transform search term in cases when parts of the query came as different GET params (when supported), e.g. 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 | create ($type=null) |
Load up the appropriate search engine class for the currently active database backend, and return a configured instance. More... | |
static | defaultNamespaces () |
An array of namespaces indexes to be searched by default. More... | |
static | getNearMatch ($searchterm) |
If an exact title match can be found, or a very slightly close match, return the title. More... | |
static | getNearMatchResultSet ($searchterm) |
Do a near match (see SearchEngine::getNearMatch) and wrap it into a SearchResultSet. More... | |
static | getOpenSearchTemplate () |
Get OpenSearch suggestion template. More... | |
static | getSearchTypes () |
Return the search engines we support. More... | |
static | legalSearchChars () |
Get chars legal for search. More... | |
static | namespacesAsText ($namespaces) |
Get a list of namespace names useful for showing in tooltips and preferences. More... | |
static | parseNamespacePrefixes ($query) |
Parse some common prefixes: all (search everything) or namespace names. More... | |
static | searchableNamespaces () |
Make a list of searchable namespaces and their canonical names. More... | |
static | userHighlightPrefs () |
Find snippet highlight settings for all users. More... | |
static | userNamespaces ($user) |
Extract default namespaces to search from the given user's settings, returning a list of index numbers. More... | |
Public Attributes | |
int[] null | $namespaces = [ NS_MAIN ] |
string | $prefix = '' |
const | COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
string profile type for completionSearch More... | |
const | FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
string profile type for query independent ranking features More... | |
Protected Member Functions | |
completionSearchBackend ($search) | |
Perform a completion search. 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 |
array string | $searchTerms = [] |
bool | $showSuggestion = true |
Private Attributes | |
$sort = 'relevance' | |
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 736 of file SearchEngine.php.
References $name, $rowAugmentors, as, Hooks\run(), and SearchResultSet\setAugmentedData().
SearchEngine::completionSearch | ( | $search | ) |
Perform a completion search.
string | $search |
Definition at line 479 of file SearchEngine.php.
References completionSearchBackend(), SearchSuggestionSet\emptySuggestionSet(), normalizeNamespaces(), and processCompletionResults().
Referenced by completionSearchWithVariants(), 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 |
Definition at line 454 of file SearchEngine.php.
References SearchSuggestionSet\fromStrings(), SearchSuggestionSet\fromTitles(), namespaces, NS_SPECIAL, Hooks\run(), and simplePrefixSearch().
Referenced by completionSearch(), and completionSearchWithVariants().
SearchEngine::completionSearchWithVariants | ( | $search | ) |
Perform a completion search with variants.
string | $search |
Definition at line 492 of file SearchEngine.php.
References $wgContLang, as, completionSearch(), completionSearchBackend(), SearchSuggestionSet\emptySuggestionSet(), global, 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 657 of file SearchEngine.php.
References $type.
|
static |
An array of namespaces indexes to be searched by default.
Definition at line 635 of file SearchEngine.php.
|
staticprotected |
Get near matcher for default SearchEngine.
Definition at line 153 of file SearchEngine.php.
SearchEngine::defaultPrefixSearch | ( | $search | ) |
Simple prefix search for subpages.
string | $search |
Definition at line 589 of file SearchEngine.php.
References normalizeNamespaces(), and simplePrefixSearch().
SearchEngine::delete | ( | $id, | |
$title | |||
) |
Delete an indexed page Title should be pre-processed.
STUB
Definition at line 369 of file SearchEngine.php.
SearchEngine::extractTitles | ( | SearchSuggestionSet | $completionResults | ) |
Extract titles from completion results.
SearchSuggestionSet | $completionResults |
Definition at line 524 of file SearchEngine.php.
References SearchSuggestion\getSuggestedTitle(), and SearchSuggestionSet\map().
|
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 165 of file SearchEngine.php.
SearchEngine::getNearMatcher | ( | Config | $config | ) |
Get service class to finding near matches.
Config | $config | Configuration to use for the matcher. |
Definition at line 144 of file SearchEngine.php.
References $wgContLang, and global.
|
static |
Do a near match (see SearchEngine::getNearMatch) and wrap it into a SearchResultSet.
string | $searchterm |
Definition at line 176 of file SearchEngine.php.
|
static |
Get OpenSearch suggestion template.
Definition at line 379 of file SearchEngine.php.
References ApiOpenSearch\getOpenSearchTemplate(), and wfDeprecated().
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 686 of file SearchEngine.php.
SearchEngine::getSearchIndexFields | ( | ) |
Get fields for search index.
Definition at line 707 of file SearchEngine.php.
References $handler, as, ContentHandler\getContentModels(), ContentHandler\getForModelID(), and Hooks\run().
|
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 667 of file SearchEngine.php.
SearchEngine::getSort | ( | ) |
Get the sort direction of the search results.
Definition at line 264 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 394 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 should be 'relevance.'
Definition at line 238 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
Definition at line 185 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 698 of file SearchEngine.php.
Referenced by ContentHandler\addSearchField(), FileContentHandler\getFieldsForSearchIndex(), WikitextContentHandler\getFieldsForSearchIndex(), TextContentHandler\getFieldsForSearchIndex(), and ContentHandler\getFieldsForSearchIndex().
|
static |
Get a list of namespace names useful for showing in tooltips and preferences.
array | $namespaces |
Definition at line 646 of file SearchEngine.php.
|
protected |
Makes search simple string if it was namespaced.
Sets namespaces of the search to namespaces extracted from string.
string | $search |
Definition at line 415 of file SearchEngine.php.
References $namespaces, $title, Title\newFromText(), NS_FILE, NS_MAIN, NS_MEDIA, Hooks\run(), 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 |
Definition at line 121 of file SearchEngine.php.
References $wgContLang, and global.
Referenced by SearchUpdate\getNormalizedTitle().
|
static |
Parse some common prefixes: all (search everything) or namespace names.
string | $query |
Definition at line 294 of file SearchEngine.php.
References $query, $wgContLang, global, and wfMessage().
|
protected |
Process completion search results.
Resolves the titles and rescores.
SearchSuggestionSet | $suggestions |
Definition at line 536 of file SearchEngine.php.
References $titles, SearchSuggestion\fromTitle(), SearchSuggestion\getSuggestedTitle(), SearchSuggestionSet\map(), namespaces, Title\newFromText(), 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 276 of file SearchEngine.php.
References $query, and namespaces.
|
static |
Make a list of searchable namespaces and their canonical names.
Definition at line 615 of file SearchEngine.php.
Referenced by setNamespaces().
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. STUB
string | $term | Raw search term |
Definition at line 71 of file SearchEngine.php.
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 83 of file SearchEngine.php.
SearchEngine::setFeatureData | ( | $feature, | |
$data | |||
) |
Way to pass custom data for engines.
string | $feature | |
mixed | $data |
Definition at line 109 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 196 of file SearchEngine.php.
Referenced by completionSearchWithVariants(), and SearchEnginePrefixTest\testSearchBackend().
SearchEngine::setNamespaces | ( | $namespaces | ) |
Set which namespaces the search should include.
Give an array of namespace index numbers.
int[]|null | $namespaces |
Definition at line 207 of file SearchEngine.php.
References $namespaces, namespaces, searchableNamespaces(), 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 227 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 250 of file SearchEngine.php.
References $sort, and getValidSorts().
|
protected |
Call out to simple search backend.
Defaults to TitlePrefixSearch.
string | $search |
Definition at line 604 of file SearchEngine.php.
References PrefixSearch\defaultSearchBackend(), and namespaces.
Referenced by completionSearchBackend(), and defaultPrefixSearch().
SearchEngine::supports | ( | $feature | ) |
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 405 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 135 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 |
Definition at line 345 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 |
Definition at line 357 of file SearchEngine.php.
|
static |
Find snippet highlight settings for all users.
Definition at line 330 of file SearchEngine.php.
|
static |
Extract default namespaces to search from the given user's settings, returning a list of index numbers.
user | $user |
Definition at line 626 of file SearchEngine.php.
References $user.
|
protected |
Feature values.
Definition at line 55 of file SearchEngine.php.
|
protected |
Definition at line 42 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult().
int [] null SearchEngine::$namespaces = [ NS_MAIN ] |
Definition at line 39 of file SearchEngine.php.
Referenced by normalizeNamespaces(), SearchMssql\queryNamespaces(), SearchOracle\queryNamespaces(), SearchSqlite\queryNamespaces(), SearchMySQL\queryNamespaces(), SearchPostgres\searchQuery(), and setNamespaces().
|
protected |
Definition at line 45 of file SearchEngine.php.
Referenced by SearchMySQL\limitResult().
string SearchEngine::$prefix = '' |
Definition at line 36 of file SearchEngine.php.
Definition at line 48 of file SearchEngine.php.
|
protected |
Definition at line 51 of file SearchEngine.php.
Referenced by setShowSuggestion().
|
private |
Definition at line 52 of file SearchEngine.php.
const SearchEngine::COMPLETION_PROFILE_TYPE = 'completionSearchProfile' |
string profile type for completionSearch
Definition at line 58 of file SearchEngine.php.
Referenced by ApiQueryPrefixSearch\getSearchProfileParams(), ApiOpenSearch\getSearchProfileParams(), and ApiOpenSearchTest\testGetAllowedParams().
const SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile' |
string profile type for query independent ranking features
Definition at line 61 of file SearchEngine.php.
Referenced by ApiQuerySearch\getSearchProfileParams().