jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/367631 )
Change subject: Properly set search limit
......................................................................
Properly set search limit
Bug: T171548
Change-Id: I6527619802b6eac98437baad46aeb21ecec16c33
Depends-On: Ib87bbe117cd7c154e10e78f76ebf8e39f7cd57a0
---
M repo/includes/Search/Elastic/WikibasePrefixSearcher.php
M repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
M repo/tests/phpunit/data/entitySearch/search_de-ch.expected
M repo/tests/phpunit/data/entitySearch/search_de-ch.query
M repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
M repo/tests/phpunit/data/entitySearch/search_en.expected
M repo/tests/phpunit/data/entitySearch/search_en_strict.expected
M repo/tests/phpunit/data/entitySearch/search_en_strict.query
M repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
M repo/tests/phpunit/data/entitySearch/search_zh.expected
M repo/tests/phpunit/includes/Search/Elastic/EntitySearchElasticTest.php
11 files changed, 27 insertions(+), 8 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/Search/Elastic/WikibasePrefixSearcher.php
b/repo/includes/Search/Elastic/WikibasePrefixSearcher.php
index f089fe4..b18d31e 100644
--- a/repo/includes/Search/Elastic/WikibasePrefixSearcher.php
+++ b/repo/includes/Search/Elastic/WikibasePrefixSearcher.php
@@ -54,6 +54,12 @@
if ( $highlight ) {
$searchQuery->setHighlight( $highlight );
}
+ if ( $this->offset ) {
+ $searchQuery->setFrom( $this->offset );
+ }
+ if ( $this->limit ) {
+ $searchQuery->setSize( $this->limit );
+ }
$searchQuery->setParam( 'rescore',
$this->searchContext->getRescore() );
return $pageType->createSearch( $searchQuery, $queryOptions );
diff --git a/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
b/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
index 8230968..297534c 100644
--- a/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected
@@ -112,6 +112,7 @@
}
}
},
+ "size": 10,
"rescore": [
{
"window_size": 8192,
@@ -147,4 +148,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
b/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
index bd3a853..7c22e89 100644
--- a/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_de-ch.expected
@@ -116,6 +116,7 @@
}
}
},
+ "size": 7,
"rescore": [
{
"window_size": 8192,
@@ -151,4 +152,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/entitySearch/search_de-ch.query
b/repo/tests/phpunit/data/entitySearch/search_de-ch.query
index 488e7a6..dcb0129 100644
--- a/repo/tests/phpunit/data/entitySearch/search_de-ch.query
+++ b/repo/tests/phpunit/data/entitySearch/search_de-ch.query
@@ -3,5 +3,6 @@
"language": "de-ch",
"userLang": "de-ch",
"type": "item",
+ "limit": 7,
"strictlanguage": false
}
diff --git a/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
b/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
index b75b2d6..ee5d863 100644
--- a/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected
@@ -109,6 +109,7 @@
}
}
},
+ "size": 10,
"rescore": [
{
"window_size": 8192,
@@ -144,4 +145,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/entitySearch/search_en.expected
b/repo/tests/phpunit/data/entitySearch/search_en.expected
index 5d7f639..5948bbe 100644
--- a/repo/tests/phpunit/data/entitySearch/search_en.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_en.expected
@@ -90,6 +90,7 @@
}
}
},
+ "size": 10,
"rescore": [
{
"window_size": 8192,
@@ -125,4 +126,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
b/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
index 81c2ca3..42f0864 100644
--- a/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_en_strict.expected
@@ -89,6 +89,7 @@
}
}
},
+ "size": 15,
"rescore": [
{
"window_size": 8192,
@@ -124,4 +125,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/entitySearch/search_en_strict.query
b/repo/tests/phpunit/data/entitySearch/search_en_strict.query
index 16706b9..8cb56a1 100644
--- a/repo/tests/phpunit/data/entitySearch/search_en_strict.query
+++ b/repo/tests/phpunit/data/entitySearch/search_en_strict.query
@@ -3,5 +3,6 @@
"language": "en",
"userLang": "en",
"type": "item",
+ "limit": 15,
"strictlanguage": true
}
diff --git a/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
b/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
index 5516e22..c98d337 100644
--- a/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_zh-de-ch.expected
@@ -193,6 +193,7 @@
}
}
},
+ "size": 10,
"rescore": [
{
"window_size": 8192,
@@ -228,4 +229,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/entitySearch/search_zh.expected
b/repo/tests/phpunit/data/entitySearch/search_zh.expected
index 1379194..092680e 100644
--- a/repo/tests/phpunit/data/entitySearch/search_zh.expected
+++ b/repo/tests/phpunit/data/entitySearch/search_zh.expected
@@ -207,6 +207,7 @@
}
}
},
+ "size": 10,
"rescore": [
{
"window_size": 8192,
@@ -242,4 +243,4 @@
"options": {
"timeout": "20s"
}
-}
+}
\ No newline at end of file
diff --git
a/repo/tests/phpunit/includes/Search/Elastic/EntitySearchElasticTest.php
b/repo/tests/phpunit/includes/Search/Elastic/EntitySearchElasticTest.php
index 2cecafe..17b2618 100644
--- a/repo/tests/phpunit/includes/Search/Elastic/EntitySearchElasticTest.php
+++ b/repo/tests/phpunit/includes/Search/Elastic/EntitySearchElasticTest.php
@@ -78,9 +78,13 @@
$search = $this->newEntitySearch( Language::factory(
$params['userLang'] ) );
$search->setRequest( $this->getMockRequest() );
$search->setReturnResult( true );
+ $limit = 10;
+ if ( isset( $params['limit'] ) ) {
+ $limit = $params['limit'];
+ }
$elasticQuery = $search->getRankedSearchResults(
$params['search'], $params['language'],
- $params['type'], 10, $params['strictlanguage']
+ $params['type'], $limit, $params['strictlanguage']
);
$decodedQuery = json_decode( $elasticQuery, true );
unset( $decodedQuery['path'] );
--
To view, visit https://gerrit.wikimedia.org/r/367631
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6527619802b6eac98437baad46aeb21ecec16c33
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits