WikidataBuilder has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377420 )

Change subject: New Wikidata Build - 2017-09-12T10:00:01+0000
......................................................................

New Wikidata Build - 2017-09-12T10:00:01+0000

Change-Id: Ifad4c343f325c187497f8c29931611efdbb919a7
---
M composer.lock
M extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php
M extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php
M extensions/Wikibase/repo/config/EntityPrefixSearchProfiles.php
M extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php
M 
extensions/Wikibase/repo/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializer.php
M extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php
M 
extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
M 
extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected
M 
extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
M 
extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh.expected
M 
extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializerTest.php
M 
extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/ChangeOpDeserializationAssert.php
M vendor/composer/installed.json
17 files changed, 1,116 insertions(+), 260 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata 
refs/changes/20/377420/1

diff --git a/composer.lock b/composer.lock
index c58c0e6..eb0dc4c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1548,12 +1548,12 @@
             "source": {
                 "type": "git",
                 "url": 
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git";,
-                "reference": "d7349aceec03e80efb4ded0ffb55cfbe337d5689"
+                "reference": "d1feae652988ba706ed795f7abd4f2d10407637a"
             },
             "dist": {
                 "type": "zip",
-                "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/d7349aceec03e80efb4ded0ffb55cfbe337d5689";,
-                "reference": "d7349aceec03e80efb4ded0ffb55cfbe337d5689",
+                "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/d1feae652988ba706ed795f7abd4f2d10407637a";,
+                "reference": "d1feae652988ba706ed795f7abd4f2d10407637a",
                 "shasum": ""
             },
             "require": {
@@ -1630,7 +1630,7 @@
                 "wikibaserepo",
                 "wikidata"
             ],
-            "time": "2017-09-11 08:32:30"
+            "time": "2017-09-12 07:46:33"
         },
         {
             "name": "wikibase/wikimedia-badges",
diff --git a/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php 
b/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php
index 6be8a22..895d02f 100644
--- a/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php
+++ b/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php
@@ -1,17 +1,24 @@
 <?php
 // ElasticSearch function for entity weight
-// TODO: this will be amended with better criteria after we ensure the 
implementation works.
+// satu function is from includes/Search/RescoreBuilders.php in CirrusSearch
+// The formula is: x^a/(k^a+x^a)
+// NOTE: that satu is always 0.5 when x == k.
+// See also: https://www.desmos.com/calculator/ahuzvkiqmi
 return [
        'entity_weight' => [
-               'score_mode' => 'max',
+               'score_mode' => 'sum',
                'functions' => [
                        [
-                               'type' => 'custom_field',
-                               'params' => [ 'field' => 'label_count', 
'missing' => 0 ]
+                               // Incoming links: k = 50
+                               'type' => 'satu',
+                               'weight' => '0.6',
+                               'params' => [ 'field' => 'incoming_links', 
'missing' => 0, 'a' => 2 , 'k' => 50 ]
                        ],
                        [
-                               'type' => 'custom_field',
-                               'params' => [ 'field' => 'sitelink_count', 
'missing' => 0 ]
+                               // Site links: k = 20
+                               'type' => 'satu',
+                               'weight' => '0.4',
+                               'params' => [ 'field' => 'sitelink_count', 
'missing' => 0, 'a' => 2, 'k' => 20 ]
                        ],
                ],
        ],
diff --git a/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php 
b/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php
index 66da453..e863b4a 100644
--- a/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php
+++ b/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php
@@ -14,7 +14,7 @@
                                'window_size_override' => 
'EntitySearchRescoreWindowSize',
                                'query_weight' => 1.0,
                                'rescore_query_weight' => 1.0,
-                               'score_mode' => 'multiply',
+                               'score_mode' => 'total',
                                'type' => 'function_score',
                                'function_chain' => 'entity_weight'
                        ],
diff --git a/extensions/Wikibase/repo/config/EntityPrefixSearchProfiles.php 
b/extensions/Wikibase/repo/config/EntityPrefixSearchProfiles.php
index 6be0288..34deca9 100644
--- a/extensions/Wikibase/repo/config/EntityPrefixSearchProfiles.php
+++ b/extensions/Wikibase/repo/config/EntityPrefixSearchProfiles.php
@@ -15,13 +15,13 @@
        // FIXME: right now these weights are completely arbitrary. We need
        // to do some work to validate them.
        'default' => [
-               'any' => 1,
-               'lang-exact' => 40,
-               'lang-folded' => 30,
-               'lang-prefix' => 15,
-               'fallback-exact' => 25,
-               'fallback-folded' => 20,
-               'fallback-prefix' => 10,
-               'fallback-discount' => 0.9,
+               'any' => 0.001,
+               'lang-exact' => 2,
+               'lang-folded' => 1.8,
+               'lang-prefix' => 1.1,
+               'fallback-exact' => 1,
+               'fallback-folded' => 0.9,
+               'fallback-prefix' => 0.8,
+               'fallback-discount' => 0.1,
        ]
 ];
diff --git a/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php 
b/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php
index df6c88e..4e8a624 100644
--- a/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php
+++ b/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php
@@ -157,11 +157,6 @@
                $newerContent = $newerRevision->getContent();
                $latestContent = $latestRevision->getContent();
 
-               // Skip diffing and patching when possible for performance 
reasons
-               if ( $newerRevision->getId() === $latestRevision->getId() ) {
-                       return $olderContent;
-               }
-
                return $latestContent->getPatchedCopy( $newerContent->getDiff( 
$olderContent ) );
        }
 
diff --git 
a/extensions/Wikibase/repo/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializer.php
 
b/extensions/Wikibase/repo/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializer.php
index adc9156..5a855a1 100644
--- 
a/extensions/Wikibase/repo/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializer.php
+++ 
b/extensions/Wikibase/repo/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializer.php
@@ -77,10 +77,6 @@
                $indexedAliases = [];
 
                foreach ( $aliasGroups as $languageCode => $aliases ) {
-                       if ( $aliases === null ) {
-                               continue;
-                       }
-
                        $this->assertIsArray( $aliases );
 
                        if ( array_values( $aliases ) !== $aliases ) {
diff --git 
a/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php 
b/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php
index 90de5bf..8489c26 100644
--- a/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php
+++ b/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php
@@ -5,6 +5,8 @@
 use CirrusSearch\Search\SearchContext;
 use Elastica\Query\AbstractQuery;
 use Elastica\Query\BoolQuery;
+use Elastica\Query\ConstantScore;
+use Elastica\Query\DisMax;
 use Elastica\Query\Match;
 use Elastica\Query\MultiMatch;
 use Elastica\Query\Term;
@@ -142,11 +144,6 @@
 
                $labelsFilter = new Match( 'labels_all.prefix', $text );
 
-               $labelsMulti = new MultiMatch();
-               $labelsMulti->setType( 'best_fields' );
-               $labelsMulti->setTieBreaker( 0 );
-               $labelsMulti->setQuery( $text );
-
                $profileName = $this->request->getVal( 'cirrusWBProfile', 
$this->settings['defaultPrefixProfile'] );
                $profile = $this->loadProfile( $profileName );
                if ( !$profile ) {
@@ -155,39 +152,41 @@
                        return $query;
                }
 
+               $dismax = new DisMax();
+               $dismax->setTieBreaker( 0 );
+
                $fields = [
-                       
"labels.{$languageCode}.near_match^{$profile['lang-exact']}",
-                       
"labels.{$languageCode}.near_match_folded^{$profile['lang-folded']}",
-                       
"labels.{$languageCode}.prefix^{$profile['lang-prefix']}",
+                       [ "labels.{$languageCode}.near_match", 
$profile['lang-exact'] ],
+                       [ "labels.{$languageCode}.near_match_folded", 
$profile['lang-folded'] ],
+                       [ "labels.{$languageCode}.prefix", 
$profile['lang-prefix'] ],
                ];
 
                $langChain = $this->languageChainFactory->newFromLanguageCode( 
$languageCode );
                $this->searchLanguageCodes = 
$langChain->getFetchLanguageCodes();
                if ( !$strictLanguage ) {
-                       $fields[] = 
"labels_all.near_match_folded^{$profile['any']}";
-                       $discount = 1;
+                       $fields[] = [ "labels_all.near_match_folded", 
$profile['any'] ];
+                       $discount = $profile['fallback-discount'];
                        foreach ( $this->searchLanguageCodes as $fallbackCode ) 
{
                                if ( $fallbackCode === $languageCode ) {
                                        continue;
                                }
                                $weight = $profile['fallback-exact'] * 
$discount;
-                               $fields[] = 
"labels.{$fallbackCode}.near_match^$weight";
+                               $fields[] = [ 
"labels.{$fallbackCode}.near_match", $weight ];
                                $weight = $profile['fallback-folded'] * 
$discount;
-                               $fields[] = 
"labels.{$fallbackCode}.near_match_folded^$weight";
+                               $fields[] = [ 
"labels.{$fallbackCode}.near_match_folded", $weight ];
                                $weight = $profile['fallback-prefix'] * 
$discount;
-                               $fields[] = 
"labels.{$fallbackCode}.prefix^$weight";
+                               $fields[] = [ "labels.{$fallbackCode}.prefix", 
$weight ];
                                $discount *= $profile['fallback-discount'];
                        }
                }
-               $labelsMulti->setFields( $fields );
+
+               foreach ( $fields as $field ) {
+                       $dismax->addQuery( $this->makeConstScoreQuery( 
$field[0], $field[1], $text ) );
+               }
 
                $labelsQuery = new BoolQuery();
                $labelsQuery->addFilter( $labelsFilter );
-               if ( $strictLanguage ) {
-                       $labelsQuery->addMust( $labelsMulti );
-               } else {
-                       $labelsQuery->addShould( $labelsMulti );
-               }
+               $labelsQuery->addMust( $dismax );
                $titleMatch = new Term( [ 'title.keyword' => $text ] );
 
                // Match either labels or exact match to title
@@ -202,6 +201,20 @@
        }
 
        /**
+        * Create constant score query for a field.
+        * @param string $field
+        * @param string|double $boost
+        * @param string $text
+        * @return ConstantScore
+        */
+       private function makeConstScoreQuery( $field, $boost, $text ) {
+               $csquery = new ConstantScore();
+               $csquery->setFilter( new Match( $field, $text ) );
+               $csquery->setBoost( $boost );
+               return $csquery;
+       }
+
+       /**
         * Get suitable rescore profile.
         * If internal config has non, return just the name and let 
RescoureBuilder handle it.
         * @return string|array
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
index 17473e8..59b17af 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
@@ -16,23 +16,111 @@
                                     }
                                 }
                             ],
-                            "should": [
+                            "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "Wien",
-                                        "fields": [
-                                            "labels.de-ch.near_match^40",
-                                            
"labels.de-ch.near_match_folded^30",
-                                            "labels.de-ch.prefix^15",
-                                            "labels_all.near_match_folded^1",
-                                            "labels.de.near_match^25",
-                                            "labels.de.near_match_folded^20",
-                                            "labels.de.prefix^10",
-                                            "labels.en.near_match^22.5",
-                                            "labels.en.near_match_folded^18",
-                                            "labels.en.prefix^9"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels_all.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.09
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.08
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.01
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.009
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.008
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -119,24 +207,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
index a34d3b8..47d506d 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
@@ -16,23 +16,111 @@
                                     }
                                 }
                             ],
-                            "should": [
+                            "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "Wien",
-                                        "fields": [
-                                            "labels.de-ch.near_match^40",
-                                            
"labels.de-ch.near_match_folded^30",
-                                            "labels.de-ch.prefix^15",
-                                            "labels_all.near_match_folded^1",
-                                            "labels.de.near_match^25",
-                                            "labels.de.near_match_folded^20",
-                                            "labels.de.prefix^10",
-                                            "labels.en.near_match^22.5",
-                                            "labels.en.near_match_folded^18",
-                                            "labels.en.prefix^9"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels_all.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.09
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.08
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.01
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.009
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 0.008
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -123,24 +211,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
index c35cd63..e2fd15d 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
@@ -18,14 +18,39 @@
                             ],
                             "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "Wien",
-                                        "fields": [
-                                            "labels.de-ch.near_match^40",
-                                            
"labels.de-ch.near_match_folded^30",
-                                            "labels.de-ch.prefix^15"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.near_match": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.near_match_folded": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.de-ch.prefix": "Wien"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -116,24 +141,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected
index 75f7a64..fa1d28b 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected
@@ -16,17 +16,51 @@
                                     }
                                 }
                             ],
-                            "should": [
+                            "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "Duck",
-                                        "fields": [
-                                            "labels.en.near_match^40",
-                                            "labels.en.near_match_folded^30",
-                                            "labels.en.prefix^15",
-                                            "labels_all.near_match_folded^1"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match_folded": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.prefix": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels_all.near_match_folded": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -97,24 +131,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
index 9b0076a..3030ae9 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
@@ -18,14 +18,39 @@
                             ],
                             "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "Duck",
-                                        "fields": [
-                                            "labels.en.near_match^40",
-                                            "labels.en.near_match_folded^30",
-                                            "labels.en.prefix^15"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match_folded": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.prefix": "Duck"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -96,24 +121,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
index bfc0ae0..a952591 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
@@ -16,44 +16,321 @@
                                     }
                                 }
                             ],
-                            "should": [
+                            "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "\u7236\u985e",
-                                        "fields": [
-                                            "labels.zh.near_match^40",
-                                            "labels.zh.near_match_folded^30",
-                                            "labels.zh.prefix^15",
-                                            "labels_all.near_match_folded^1",
-                                            "labels.zh-hans.near_match^25",
-                                            
"labels.zh-hans.near_match_folded^20",
-                                            "labels.zh-hans.prefix^10",
-                                            "labels.zh-hant.near_match^22.5",
-                                            
"labels.zh-hant.near_match_folded^18",
-                                            "labels.zh-hant.prefix^9",
-                                            "labels.zh-cn.near_match^20.25",
-                                            
"labels.zh-cn.near_match_folded^16.2",
-                                            "labels.zh-cn.prefix^8.1",
-                                            "labels.zh-tw.near_match^18.225",
-                                            
"labels.zh-tw.near_match_folded^14.58",
-                                            "labels.zh-tw.prefix^7.29",
-                                            "labels.zh-hk.near_match^16.4025",
-                                            
"labels.zh-hk.near_match_folded^13.122",
-                                            "labels.zh-hk.prefix^6.561",
-                                            "labels.zh-sg.near_match^14.76225",
-                                            
"labels.zh-sg.near_match_folded^11.8098",
-                                            "labels.zh-sg.prefix^5.9049",
-                                            
"labels.zh-mo.near_match^13.286025",
-                                            
"labels.zh-mo.near_match_folded^10.62882",
-                                            "labels.zh-mo.prefix^5.31441",
-                                            
"labels.zh-my.near_match^11.9574225",
-                                            
"labels.zh-my.near_match_folded^9.565938",
-                                            "labels.zh-my.prefix^4.782969",
-                                            "labels.en.near_match^10.76168025",
-                                            
"labels.en.near_match_folded^8.6093442",
-                                            "labels.en.prefix^4.3046721"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels_all.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hans.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hans.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.09
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hans.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.08
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hant.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.01
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hant.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.009
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hant.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.008
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-cn.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-cn.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.0009
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-cn.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.0008
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-tw.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.0001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-tw.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-5
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-tw.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-5
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hk.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-5
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hk.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-6
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hk.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-6
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-sg.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-6
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-sg.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-7
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-sg.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-7
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-mo.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-7
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-mo.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-mo.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-my.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-my.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-9
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-my.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-9
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-9
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-10
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-10
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -200,24 +477,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh.expected 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh.expected
index 56a0756..ae8061e 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh.expected
+++ 
b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_zh.expected
@@ -16,44 +16,321 @@
                                     }
                                 }
                             ],
-                            "should": [
+                            "must": [
                                 {
-                                    "multi_match": {
-                                        "type": "best_fields",
+                                    "dis_max": {
                                         "tie_breaker": 0,
-                                        "query": "\u7236\u985e",
-                                        "fields": [
-                                            "labels.zh.near_match^40",
-                                            "labels.zh.near_match_folded^30",
-                                            "labels.zh.prefix^15",
-                                            "labels_all.near_match_folded^1",
-                                            "labels.zh-hans.near_match^25",
-                                            
"labels.zh-hans.near_match_folded^20",
-                                            "labels.zh-hans.prefix^10",
-                                            "labels.zh-hant.near_match^22.5",
-                                            
"labels.zh-hant.near_match_folded^18",
-                                            "labels.zh-hant.prefix^9",
-                                            "labels.zh-cn.near_match^20.25",
-                                            
"labels.zh-cn.near_match_folded^16.2",
-                                            "labels.zh-cn.prefix^8.1",
-                                            "labels.zh-tw.near_match^18.225",
-                                            
"labels.zh-tw.near_match_folded^14.58",
-                                            "labels.zh-tw.prefix^7.29",
-                                            "labels.zh-hk.near_match^16.4025",
-                                            
"labels.zh-hk.near_match_folded^13.122",
-                                            "labels.zh-hk.prefix^6.561",
-                                            "labels.zh-sg.near_match^14.76225",
-                                            
"labels.zh-sg.near_match_folded^11.8098",
-                                            "labels.zh-sg.prefix^5.9049",
-                                            
"labels.zh-mo.near_match^13.286025",
-                                            
"labels.zh-mo.near_match_folded^10.62882",
-                                            "labels.zh-mo.prefix^5.31441",
-                                            
"labels.zh-my.near_match^11.9574225",
-                                            
"labels.zh-my.near_match_folded^9.565938",
-                                            "labels.zh-my.prefix^4.782969",
-                                            "labels.en.near_match^10.76168025",
-                                            
"labels.en.near_match_folded^8.6093442",
-                                            "labels.en.prefix^4.3046721"
+                                        "queries": [
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 2
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels_all.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hans.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.1
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hans.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.09
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hans.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.08
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hant.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.01
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hant.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.009
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hant.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.008
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-cn.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-cn.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.0009
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-cn.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.0008
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-tw.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 0.0001
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-tw.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-5
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-tw.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-5
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hk.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-5
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hk.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-6
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-hk.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-6
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-sg.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-6
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-sg.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-7
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-sg.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-7
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-mo.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-7
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-mo.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-mo.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-my.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-8
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-my.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-9
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.zh-my.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-9
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 1.0e-9
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.near_match_folded": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 9.0e-10
+                                                }
+                                            },
+                                            {
+                                                "constant_score": {
+                                                    "filter": {
+                                                        "match": {
+                                                            
"labels.en.prefix": "\u7236\u985e"
+                                                        }
+                                                    },
+                                                    "boost": 8.0e-10
+                                                }
+                                            }
                                         ]
                                     }
                                 }
@@ -214,24 +491,28 @@
                 "query": {
                     "query_weight": 1,
                     "rescore_query_weight": 1,
-                    "score_mode": "multiply",
+                    "score_mode": "total",
                     "rescore_query": {
                         "function_score": {
-                            "score_mode": "max",
+                            "score_mode": "sum",
                             "functions": [
                                 {
-                                    "field_value_factor": {
-                                        "field": "label_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) 
+ pow(50,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.6
                                 },
                                 {
-                                    "field_value_factor": {
-                                        "field": "sitelink_count",
-                                        "missing": 0
+                                    "script_score": {
+                                        "script": {
+                                            "inline": 
"pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) 
+ pow(20,2))",
+                                            "lang": "expression"
+                                        }
                                     },
-                                    "weight": 1
+                                    "weight": 0.4
                                 }
                             ]
                         }
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializerTest.php
 
b/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializerTest.php
index f5b504e..67deb71 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializerTest.php
+++ 
b/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializerTest.php
@@ -33,17 +33,23 @@
                );
        }
 
-       public function testGivenAliasesAsNull_isIgnored() {
-               $deserializer = $this->newAliasesChangeOpDeserializer( 
$this->getTermChangeOpValidator() );
-               $changeOp = $deserializer->createEntityChangeOp( [ 'aliases' => 
[ 'en' => null ] ] );
-               $this->assertEquals( new ChangeOps(), $changeOp );
+       public function provideInvalidAliasesArray() {
+               return [
+                       [ null ],
+                       [ false ],
+                       [ 1 ],
+                       [ 'alias1|alias2' ],
+               ];
        }
 
-       public function 
testGivenAliasesNotAsArray_createEntityChangeOpThrowsError() {
+       /**
+        * @dataProvider provideInvalidAliasesArray
+        */
+       public function 
testGivenAliasesForLanguageNotAnArray_createEntityChangeOpThrowsError( $aliases 
) {
                
ChangeOpDeserializationAssert::assertThrowsChangeOpDeserializationException(
-                       function() {
+                       function () use ( $aliases ) {
                                $deserializer = 
$this->newAliasesChangeOpDeserializer( $this->getTermChangeOpValidator() );
-                               $deserializer->createEntityChangeOp( [ 
'aliases' => [ 'en' => 'alias1|alias2' ] ] );
+                               $deserializer->createEntityChangeOp( [ 
'aliases' => [ 'en' => $aliases ] ] );
                        },
                        'not-recognized-array'
                );
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/ChangeOpDeserializationAssert.php
 
b/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/ChangeOpDeserializationAssert.php
index e7ffa1b..a7b0051 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/ChangeOpDeserializationAssert.php
+++ 
b/extensions/Wikibase/repo/tests/phpunit/includes/ChangeOp/Deserialization/ChangeOpDeserializationAssert.php
@@ -13,17 +13,14 @@
         * @param string $errorCode
         */
        public static function assertThrowsChangeOpDeserializationException( 
callable $callback, $errorCode ) {
-               $exception = null;
-
                try {
                        call_user_func( $callback );
-               } catch ( Exception $e ) {
-                       $exception = $e;
+               } catch ( ChangeOpDeserializationException $ex ) {
+                       Assert::assertSame( $errorCode, $ex->getErrorCode() );
+                       return;
                }
 
-               /** @var $exception ChangeOpDeserializationException */
-               Assert::assertInstanceOf( 
ChangeOpDeserializationException::class, $exception );
-               Assert::assertSame( $errorCode, $exception->getErrorCode() );
+               Assert::fail( 'Expected ChangeOpDeserializationException not 
thrown' );
        }
 
 }
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 9b40045..56a4814 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -1389,12 +1389,12 @@
         "source": {
             "type": "git",
             "url": 
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git";,
-            "reference": "d7349aceec03e80efb4ded0ffb55cfbe337d5689"
+            "reference": "d1feae652988ba706ed795f7abd4f2d10407637a"
         },
         "dist": {
             "type": "zip",
-            "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/d7349aceec03e80efb4ded0ffb55cfbe337d5689";,
-            "reference": "d7349aceec03e80efb4ded0ffb55cfbe337d5689",
+            "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/d1feae652988ba706ed795f7abd4f2d10407637a";,
+            "reference": "d1feae652988ba706ed795f7abd4f2d10407637a",
             "shasum": ""
         },
         "require": {
@@ -1428,7 +1428,7 @@
             "jakub-onderka/php-parallel-lint": ">=0.3 <0.10",
             "wikibase/wikibase-codesniffer": "^0.1.0"
         },
-        "time": "2017-09-11 08:32:30",
+        "time": "2017-09-12 07:46:33",
         "type": "mediawiki-extension",
         "installation-source": "dist",
         "autoload": {

-- 
To view, visit https://gerrit.wikimedia.org/r/377420
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifad4c343f325c187497f8c29931611efdbb919a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata
Gerrit-Branch: master
Gerrit-Owner: WikidataBuilder <wikidata-servi...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to