33 parent::__construct(
$query, $moduleName,
'ps' );
41 $this->
run( $resultPageSet );
47 private function run( $resultPageSet =
null ) {
54 $titles = $searchEngine->extractTitles( $searchEngine->completionSearchWithVariants( $search ) );
56 if ( $resultPageSet ) {
57 $resultPageSet->setRedirectMergePolicy(
function ( array $current, array $new ) {
58 if ( !isset( $current[
'index'] ) || $new[
'index'] < $current[
'index'] ) {
59 $current[
'index'] = $new[
'index'];
63 if ( count(
$titles ) > $limit ) {
67 $resultPageSet->populateFromTitles(
$titles );
68 foreach (
$titles as $index => $title ) {
69 $resultPageSet->setGeneratorData( $title, [
'index' => $index + $offset + 1 ] );
75 if ( ++$count > $limit ) {
80 'ns' => intval( $title->getNamespace() ),
81 'title' => $title->getPrefixedText(),
83 if ( $title->isSpecialPage() ) {
84 $vals[
'special'] =
true;
86 $vals[
'pageid'] = intval( $title->getArticleID() );
88 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
94 $result->addIndexedTagName(
105 if ( $this->allowedParams !==
null ) {
116 'profile-type' => SearchEngine::COMPLETION_PROFILE_TYPE,
117 'help-message' =>
'apihelp-query+prefixsearch-param-profile',
124 'action=query&list=prefixsearch&pssearch=meaning'
125 =>
'apihelp-query+prefixsearch-example-simple',
130 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Prefixsearch';
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when run
buildSearchEngine(array $params=null)
Build the search engine to use.
buildCommonApiParams( $isScrollable=true)
The set of api parameters that are shared between api calls that call the SearchEngine.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getResult()
Get the result object.
getModuleName()
Get the name of the module being executed by this instance.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
array $allowedParams
list of api allowed params
getHelpUrls()
Return links to more detailed help pages about the module.
__construct( $query, $moduleName)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
executeGenerator( $resultPageSet)
Execute this module as a generator.
run( $resultPageSet=null)
getExamplesMessages()
Returns usage examples for this module.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
trait SearchApi
Traits for API components that use a SearchEngine.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles