Go to the documentation of this file.
33 parent::__construct( $query, $moduleName,
'ps' );
41 $this->
run( $resultPageSet );
47 private function run( $resultPageSet =
null ) {
49 $search = $params[
'search'];
50 $limit = $params[
'limit'];
51 $offset = $params[
'offset'];
54 $suggestions = $searchEngine->completionSearchWithVariants( $search );
55 $titles = $searchEngine->extractTitles( $suggestions );
57 if ( $suggestions->hasMoreResults() ) {
61 if ( $resultPageSet ) {
62 $resultPageSet->setRedirectMergePolicy(
function ( array $current, array $new ) {
63 if ( !isset( $current[
'index'] ) || $new[
'index'] < $current[
'index'] ) {
64 $current[
'index'] = $new[
'index'];
68 $resultPageSet->populateFromTitles( $titles );
69 foreach ( $titles as $index =>
$title ) {
70 $resultPageSet->setGeneratorData(
$title, [
'index' => $index + $offset + 1 ] );
75 foreach ( $titles as
$title ) {
77 'ns' => (int)
$title->getNamespace(),
78 'title' =>
$title->getPrefixedText(),
80 if (
$title->isSpecialPage() ) {
81 $vals[
'special'] =
true;
83 $vals[
'pageid'] = (int)
$title->getArticleID();
85 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
92 $result->addIndexedTagName(
103 if ( $this->allowedParams !==
null ) {
115 'help-message' =>
'apihelp-query+prefixsearch-param-profile',
122 'action=query&list=prefixsearch&pssearch=meaning'
123 =>
'apihelp-query+prefixsearch-example-simple',
128 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Prefixsearch';
getCacheMode( $params)
Get the cache mode for the data generated by this module.
array $allowedParams
list of api allowed params
getResult()
Get the result object.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
const COMPLETION_PROFILE_TYPE
Profile type for completionSearch.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
buildSearchEngine(array $params=null)
Build the search engine to use.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
executeGenerator( $resultPageSet)
Execute this module as a generator.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct( $query, $moduleName)
run( $resultPageSet=null)
getModuleName()
Get the name of the module being executed by this instance.
trait SearchApi
Traits for API components that use a SearchEngine.
getExamplesMessages()
Returns usage examples for this module.
buildCommonApiParams( $isScrollable=true)
The set of api parameters that are shared between api calls that call the SearchEngine.