Improve ULS language search api

* Store prefixes and infixes separately in the data
* First match language code, then prefixes, then infixes
* Try to use suggestion either in user language or autonym first
* use formatversion=2 to avoid escaping Unicode

Using Language::fetchLanguageName might can have a small
performance impact. On the other hand there is now check
to skip languages we already found, avoiding some fuzzy
matching.

This is in a preparation for a change in jquery.uls to use
the search API more, while trying to reduce the amount of
weird autocompletion suggestions we show to the user.

Bug: T73891
Change-Id: Id94c5352d9a591969bf90144d1d2d5e758d08301
This commit is contained in:
Niklas Laxström
2017-11-27 12:22:25 +01:00
parent a353c5ab65
commit e87dd20cdd
6 changed files with 51632 additions and 46567 deletions

View File

@@ -22,12 +22,11 @@
* @ingroup API
*/
class ApiLanguageSearch extends ApiBase {
public function execute() {
$params = $this->extractRequestParams();
$search = $params['search'];
$typos = $params['typos'];
$searches = LanguageNameSearch::search( $search, $typos );
$searches = LanguageNameSearch::search( $search, $typos, $this->getLanguage()->getCode() );
$result = $this->getResult();
$result->addValue( null, $this->getModuleName(), $searches );
}