CirrusSearch
Elasticsearch-powered search for MediaWiki
|
Service to manage and access search profiles. More...
Public Member Functions | |
__construct (UserOptionsLookup $userOptionsLookup, ?WebRequest $request=null, ?UserIdentity $user=null) | |
hasProfile ( $type, $name) | |
supportsContext ( $type, $context) | |
loadProfileByName ( $type, $name, $failIfMissing=true) | |
Load a profile by its name. | |
loadProfile ( $type, $context=self::CONTEXT_DEFAULT, $name=null, $contextParams=[]) | |
Load a profile for the context or by its name if name is provided. | |
getProfileName ( $type, $context=self::CONTEXT_DEFAULT, array $contextParams=[]) | |
registerRepository (SearchProfileRepository $repository) | |
Register a new profile repository. | |
registerArrayRepository ( $repoType, $repoName, array $profiles) | |
Register a new repository backed by a simple array. | |
registerFileRepository ( $type, $name, $phpFile) | |
Register a new repository backed by a PHP file returning an array. | |
listExposedProfiles ( $type) | |
List profiles under type $type that are suited to be exposed to the users. | |
registerDefaultProfile ( $type, $profileContext, $profileName) | |
Register a default profile named $profileName for $type in context $profileContext It must be an existing profile otherwise it will always fail when trying to determine the profile name. | |
registerProfileOverride ( $type, $profileContext, SearchProfileOverride $override) | |
Register a new profile overrider. | |
registerConfigOverride ( $type, $profileContext, Config $config, $configEntry) | |
Register a new overrider using the ConfigSearchProfileOverride implementation. | |
registerUriParamOverride ( $type, $profileContext, $uriParam) | |
registerUserPrefOverride ( $type, $profileContext, $userPref) | |
registerContextualOverride ( $type, $profileContext, $template, array $params) | |
registerSearchQueryRoute (SearchQueryRoute $route) | |
Register a new route to be used by the SearchQueryDispatchService. | |
registerFTSearchQueryRoute ( $profileContext, $score, array $supportedNamespaces, array $acceptableQueryClasses=[]) | |
Register a new static route for fulltext search queries. | |
getDispatchService () | |
Return the service responsible for dispatching a SearchQuery to its preferred profile context. | |
freeze () | |
Freeze the service, any attempt to declare a new repository will fail. | |
listProfileTypes () | |
listProfileContexts ( $type) | |
List default profile per context. | |
listProfileRepositories ( $type) | |
List profile repositories. | |
listProfileOverrides ( $type, $context) | |
L. | |
Public Attributes | |
const | CROSS_PROJECT_BLOCK_SCORER = 'crossproject_block_scorer' |
Profile type for ordering crossproject result blocks. | |
const | SIMILARITY = 'similarity' |
Profile type for similarity configuration Used when building the indices. | |
const | RESCORE = 'rescore' |
Profile type for rescoring components Used at query when building elastic queries. | |
const | RESCORE_FUNCTION_CHAINS = 'rescore_function_chains' |
Profile type used to build function chains Used at query time by rescore builders. | |
const | COMPLETION = 'completion' |
Profile type used by the completion suggester. | |
const | PHRASE_SUGGESTER = 'phrase_suggester' |
Profile type used by the phrase suggester (fulltext search only) | |
const | INDEX_LOOKUP_FALLBACK = 'index_lookup_fallback' |
Profile type used by the index lookup fallback method method. | |
const | SANEITIZER = 'saneitizer' |
Profile type used by saneitizer. | |
const | DOCUMENT_SIZE_LIMITER = 'document_size_limiter' |
Profile type used by the document size limiter. | |
const | FT_QUERY_BUILDER = 'ft_query_builder' |
Profiles used for building fulltext search queries. | |
const | FALLBACKS = 'fallbacks' |
Profile type used by FallbackRunner. | |
const | CONTEXT_PREFIXSEARCH = 'prefixsearch' |
Profile context used for prefix search queries. | |
const | CONTEXT_DEFAULT = 'default' |
Default profile context (used by fulltext queries) | |
Service to manage and access search profiles.
Search profiles are arranged by type identified by a string constant:
Multiple repository per type can be declared, in general we have:
The service is bound to a SearchConfig instance which means that the profiles may vary depending on the SearchConfig being used. The cirrus_base repository will always hold the same set of profiles but the cirrus_config may change according to SearchConfig content.
The service is also responsible for determining the name of the default profile for a given context. The profile context is a notion introduced to allow using the same profile for multiple purposes. For example the rescore profiles may be used for different kind of queries (fulltext vs prefixsearch). While they share the same set of profiles we may prefer to use different defaults depending on the type of the query. The profile context allows to distinguish between these use cases.
Then in order to customize the default profile the service allows to define a list of "overriders":
CirrusSearch\Profile\SearchProfileService::__construct | ( | UserOptionsLookup | $userOptionsLookup, |
?WebRequest | $request = null, | ||
?UserIdentity | $user = null ) |
UserOptionsLookup | $userOptionsLookup | |
WebRequest | null | $request | obtained from \RequestContext::getMain()->getRequest() if null |
UserIdentity | null | $user | obtained from \RequestContext::getMain()->getUser() if null |
CirrusSearch\Profile\SearchProfileService::getDispatchService | ( | ) |
Return the service responsible for dispatching a SearchQuery to its preferred profile context.
CirrusSearch\Profile\SearchProfileService::getProfileName | ( | $type, | |
$context = self::CONTEXT_DEFAULT, | |||
array | $contextParams = [] ) |
string | $type | the type of the profile (see class doc) |
string | $context | |
string[] | $contextParams | Parameters of the context, for determining the profile name. Some overriders use these to decide if an override is appropriate. |
CirrusSearch\Profile\SearchProfileService::hasProfile | ( | $type, | |
$name ) |
string | $type | |
string | $name |
CirrusSearch\Profile\SearchProfileService::listExposedProfiles | ( | $type | ) |
List profiles under type $type that are suited to be exposed to the users.
This method is provided for convenience and to help users to discover existing profile. It's possible that an existing profile may not be listed here so this method must not be used to verify the existence of a given profile. Use hasProfile instead.
string | $type |
CirrusSearch\Profile\SearchProfileService::listProfileContexts | ( | $type | ) |
List default profile per context.
string | $type |
CirrusSearch\Profile\SearchProfileService::listProfileOverrides | ( | $type, | |
$context ) |
L.
string | $type | |
string | $context |
CirrusSearch\Profile\SearchProfileService::listProfileRepositories | ( | $type | ) |
List profile repositories.
string | $type |
CirrusSearch\Profile\SearchProfileService::listProfileTypes | ( | ) |
CirrusSearch\Profile\SearchProfileService::loadProfile | ( | $type, | |
$context = self::CONTEXT_DEFAULT, | |||
$name = null, | |||
$contextParams = [] ) |
Load a profile for the context or by its name if name is provided.
string | $type | |
string | $context | used to determine the name of the profile if $name is not provided |
string | null | $name | force the name of the profile to use |
string[] | $contextParams | Parameters of the context, for determining the profile name. Some overriders use these to decide if an override is appropriate. |
CirrusSearch\Profile\SearchProfileService::loadProfileByName | ( | $type, | |
$name, | |||
$failIfMissing = true ) |
Load a profile by its name.
It's better to use self::loadProfile and let the service determine the proper profile to use in a given context.
string | $type | the type of the profile (see class doc) |
string | $name | |
bool | $failIfMissing | when true will throw SearchProfileException |
CirrusSearch\Profile\SearchProfileService::registerArrayRepository | ( | $repoType, | |
$repoName, | |||
array | $profiles ) |
Register a new repository backed by a simple array.
string | $repoType | |
string | $repoName | |
array | $profiles |
CirrusSearch\Profile\SearchProfileService::registerConfigOverride | ( | $type, | |
$profileContext, | |||
Config | $config, | ||
$configEntry ) |
Register a new overrider using the ConfigSearchProfileOverride implementation.
string | $type | |
string | string[] | $profileContext | one or multiple contexts |
Config | $config | |
string | $configEntry |
CirrusSearch\Profile\SearchProfileService::registerContextualOverride | ( | $type, | |
$profileContext, | |||
$template, | |||
array | $params ) |
string | $type | |
string | string[] | $profileContext | one or multiple contexts |
string | $template | A templated profile name |
string[] | $params | Map from string in $template to context parameter to replace with. All params must be available in the context parameters or no override will be applied. |
CirrusSearch\Profile\SearchProfileService::registerDefaultProfile | ( | $type, | |
$profileContext, | |||
$profileName ) |
Register a default profile named $profileName for $type in context $profileContext It must be an existing profile otherwise it will always fail when trying to determine the profile name.
string | $type | |
string | $profileContext | |
string | $profileName |
CirrusSearch\Profile\SearchProfileService::registerFileRepository | ( | $type, | |
$name, | |||
$phpFile ) |
Register a new repository backed by a PHP file returning an array.
NOTE: $phpFile is loaded with PHP's require keyword.
string | $type | |
string | $name | |
string | $phpFile |
CirrusSearch\Profile\SearchProfileService::registerFTSearchQueryRoute | ( | $profileContext, | |
$score, | |||
array | $supportedNamespaces, | ||
array | $acceptableQueryClasses = [] ) |
Register a new static route for fulltext search queries.
string | $profileContext | |
float | $score | score of the route |
int[] | $supportedNamespaces | |
string[] | $acceptableQueryClasses |
CirrusSearch\Profile\SearchProfileService::registerProfileOverride | ( | $type, | |
$profileContext, | |||
SearchProfileOverride | $override ) |
Register a new profile overrider.
It allows to override the default profile based on the implementation of SearchProfileOverride.
string | $type | |
string | string[] | $profileContext | one or multiple contexts |
SearchProfileOverride | $override |
CirrusSearch\Profile\SearchProfileService::registerRepository | ( | SearchProfileRepository | $repository | ) |
Register a new profile repository.
SearchProfileRepository | $repository |
CirrusSearch\Profile\SearchProfileService::registerSearchQueryRoute | ( | SearchQueryRoute | $route | ) |
Register a new route to be used by the SearchQueryDispatchService.
SearchQueryRoute | $route |
CirrusSearch\Profile\SearchProfileService::registerUriParamOverride | ( | $type, | |
$profileContext, | |||
$uriParam ) |
string | $type | |
string | string[] | $profileContext | one or multiple contexts |
string | $uriParam |
CirrusSearch\Profile\SearchProfileService::registerUserPrefOverride | ( | $type, | |
$profileContext, | |||
$userPref ) |
string | $type | |
string | string[] | $profileContext | one or multiple contexts |
string | $userPref | the name of the key used to store this user preference |
CirrusSearch\Profile\SearchProfileService::supportsContext | ( | $type, | |
$context ) |
string | $type | |
string | $context |
const CirrusSearch\Profile\SearchProfileService::COMPLETION = 'completion' |
Profile type used by the completion suggester.
const CirrusSearch\Profile\SearchProfileService::DOCUMENT_SIZE_LIMITER = 'document_size_limiter' |
Profile type used by the document size limiter.
const CirrusSearch\Profile\SearchProfileService::FALLBACKS = 'fallbacks' |
Profile type used by FallbackRunner.
const CirrusSearch\Profile\SearchProfileService::FT_QUERY_BUILDER = 'ft_query_builder' |
Profiles used for building fulltext search queries.
const CirrusSearch\Profile\SearchProfileService::INDEX_LOOKUP_FALLBACK = 'index_lookup_fallback' |
Profile type used by the index lookup fallback method method.
const CirrusSearch\Profile\SearchProfileService::PHRASE_SUGGESTER = 'phrase_suggester' |
Profile type used by the phrase suggester (fulltext search only)
const CirrusSearch\Profile\SearchProfileService::RESCORE = 'rescore' |
Profile type for rescoring components Used at query when building elastic queries.
const CirrusSearch\Profile\SearchProfileService::RESCORE_FUNCTION_CHAINS = 'rescore_function_chains' |
Profile type used to build function chains Used at query time by rescore builders.
const CirrusSearch\Profile\SearchProfileService::SANEITIZER = 'saneitizer' |
Profile type used by saneitizer.