// Create search engine instance and set options
$search = $this->buildSearchEngine( $params );
+ if ( isset( $params['sort'] ) ) {
+ $search->setSort( $params['sort'] );
+ }
$search->setFeatureData( 'rewrite', (bool)$params['enablerewrites'] );
$search->setFeatureData( 'interwiki', (bool)$interwiki );
'enablerewrites' => false,
];
+ // If we have more than one engine the list of available sorts is
+ // difficult to represent. For now don't expose it.
+ $alternatives = MediaWiki\MediaWikiServices::getInstance()
+ ->getSearchEngineConfig()
+ ->getSearchTypes();
+ if ( count( $alternatives ) == 1 ) {
+ $this->allowedParams['sort'] = [
+ ApiBase::PARAM_DFLT => 'relevance',
+ ApiBase::PARAM_TYPE => MediaWiki\MediaWikiServices::getInstance()
+ ->newSearchEngine()
+ ->getValidSorts(),
+ ];
+ }
+
return $this->allowedParams;
}
"apihelp-query+search-param-interwiki": "Include interwiki results in the search, if available.",
"apihelp-query+search-param-backend": "Which search backend to use, if not the default.",
"apihelp-query+search-param-enablerewrites": "Enable internal query rewriting. Some search backends can rewrite the query into another which is thought to provide better results, for instance by correcting spelling errors.",
+ "apihelp-query+search-param-sort": "Set the sort order of returned results.",
"apihelp-query+search-example-simple": "Search for <kbd>meaning</kbd>.",
"apihelp-query+search-example-text": "Search texts for <kbd>meaning</kbd>.",
"apihelp-query+search-example-generator": "Get page info about the pages returned for a search for <kbd>meaning</kbd>.",
"apihelp-query+search-param-interwiki": "{{doc-apihelp-param|query+search|interwiki}}",
"apihelp-query+search-param-backend": "{{doc-apihelp-param|query+search|backend}}",
"apihelp-query+search-param-enablerewrites": "{{doc-apihelp-param|query+search|enablerewrites}}",
+ "apihelp-query+search-param-sort": "{{doc-apihelp-param|query+search|sort}}",
"apihelp-query+search-example-simple": "{{doc-apihelp-example|query+search}}",
"apihelp-query+search-example-text": "{{doc-apihelp-example|query+search}}",
"apihelp-query+search-example-generator": "{{doc-apihelp-example|query+search}}",
"rcfilters-empty-filter": "No active filters. All contributions are shown.",
"rcfilters-filterlist-title": "Filters",
"rcfilters-filterlist-whatsthis": "How do these work?",
- "rcfilters-filterlist-feedbacklink": "Tell us what you think about these (new) filtering tools",
+ "rcfilters-filterlist-feedbacklink": "Tell us what you think about these filtering tools",
"rcfilters-highlightbutton-title": "Highlight results",
"rcfilters-highlightmenu-title": "Select a color",
"rcfilters-highlightmenu-help": "Select a color to highlight this property",