MediaWiki  master
SearchApi.php File Reference

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. More...

Go to the source code of this file.

Functions

 buildCommonApiParams ( $isScrollable=true)
 The set of api parameters that are shared between api calls that call the SearchEngine. More...
 
 buildProfileApiParam ()
 Build the profile api param definitions. More...
 
 buildSearchEngine (array $params=null)
 Build the search engine to use. More...
 
 checkDependenciesSet ()
 
 getContext ()
 
 getSearchProfileParams ()
 

Variables

static $BACKEND_NULL_PARAM = 'database-backed'
 When $wgSearchType is null, $wgSearchAlternatives[0] is null. More...
 
SearchEngineFactory null $searchEngineFactory = null
 
trait SearchApi
 Traits for API components that use a SearchEngine. More...
 

Detailed Description

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Since
1.28

Definition in file SearchApi.php.

Function Documentation

◆ buildCommonApiParams()

buildCommonApiParams (   $isScrollable = true)

The set of api parameters that are shared between api calls that call the SearchEngine.

Primarily this defines parameters that are utilized by self::buildSearchEngine().

Parameters
bool$isScrollableTrue if the api offers scrolling
Returns
array

Definition at line 63 of file SearchApi.php.

References $BACKEND_NULL_PARAM, buildProfileApiParam(), checkDependenciesSet(), ApiBase\LIMIT_BIG1, ApiBase\LIMIT_BIG2, NS_MAIN, ApiBase\PARAM_DFLT, ApiBase\PARAM_HELP_MSG, ApiBase\PARAM_ISMULTI, ApiBase\PARAM_MAX, ApiBase\PARAM_MAX2, ApiBase\PARAM_MIN, ApiBase\PARAM_REQUIRED, and ApiBase\PARAM_TYPE.

Referenced by ApiOpenSearch\getAllowedParams(), ApiQueryPrefixSearch\getAllowedParams(), and ApiQuerySearch\getAllowedParams().

◆ buildProfileApiParam()

buildProfileApiParam ( )
private

Build the profile api param definitions.

Makes bold assumption only one search engine is available, ensure that is true before calling.

Returns
array array containing available additional api param definitions. Empty if profiles are not supported by the searchEngine implementation.

Definition at line 121 of file SearchApi.php.

References checkDependenciesSet(), getContext(), getSearchProfileParams(), ApiBase\PARAM_DFLT, ApiBase\PARAM_HELP_MSG, ApiBase\PARAM_HELP_MSG_PER_VALUE, and ApiBase\PARAM_TYPE.

Referenced by buildCommonApiParams().

◆ buildSearchEngine()

buildSearchEngine ( array  $params = null)

Build the search engine to use.

If $params is provided then the following searchEngine options will be set:

  • backend: which search backend to use
  • limit: mandatory
  • offset: optional
  • namespace: mandatory
  • search engine profiles defined by SearchApi::getSearchProfileParams()
    Parameters
    string[] | null$paramsAPI request params (must be sanitized by ApiBase::extractRequestParams() before)
    Returns
    SearchEngine

Definition at line 174 of file SearchApi.php.

References $BACKEND_NULL_PARAM, $type, checkDependenciesSet(), and getSearchProfileParams().

Referenced by ApiQueryPrefixSearch\run(), ApiQuerySearch\run(), and ApiOpenSearch\search().

◆ checkDependenciesSet()

checkDependenciesSet ( )
private

Definition at line 35 of file SearchApi.php.

Referenced by buildCommonApiParams(), buildProfileApiParam(), and buildSearchEngine().

◆ getContext()

◆ getSearchProfileParams()

getSearchProfileParams ( )
abstract
Returns
array[] array of arrays mapping from parameter name to a two value map containing 'help-message' and 'profile-type' keys.

Referenced by buildProfileApiParam(), and buildSearchEngine().

Variable Documentation

◆ $BACKEND_NULL_PARAM

$BACKEND_NULL_PARAM = 'database-backed'
staticprivate

When $wgSearchType is null, $wgSearchAlternatives[0] is null.

Null isn't a valid option for an array for PARAM_TYPE, so we'll use a fake name that can't possibly be a class name and describes what the null behavior does

Definition at line 53 of file SearchApi.php.

Referenced by buildCommonApiParams(), and buildSearchEngine().

◆ $searchEngineFactory

SearchEngineFactory null $searchEngineFactory = null
private