Convenience library for making searches for titles that match a string.
Loaded via the mediawiki.searchSuggest ResourceLoader library.
Example
mw.loader.using('mediawiki.searchSuggest').then(() => {
var api = new mw.Api();
mw.searchSuggest.request(api, 'Dogs that', ( results ) => {
alert( `Results that match: ${results.join( '\n' );}` );
});
});
Methods
request(api, query, response, [limit], [namespace]) → {jQuery.Deferred}static
#
Queries the wiki and calls response with the result.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
api |
mw.Api | ||
query |
string | ||
response |
mw.searchSuggest~ResponseFunction | ||
limit |
string | number |
optional |
|
namespace |
string | number | Array.<string> | Array.<number> |
optional |
Returns:
- Type
- jQuery.Deferred
Queries the wiki and calls response with the result.
Type Definitions
ResponseFunction(titles, meta)
#
Parameters:
| Name | Type | Description |
|---|---|---|
titles |
Array.<string> | titles of pages that match search |
meta |
mw.searchSuggest~ResponseMetaData | meta data relating to search. |
ResponseMetaData
#
Type:
Properties:
| Name | Type | Description |
|---|---|---|
type |
string | the contents of the X-OpenSearch-Type response header. |
searchId |
string | the contents of the X-Search-ID response header. |
query |
string |