DCausse has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/360358 )
Change subject: Add noop hints for LabelsField
......................................................................
Add noop hints for LabelsField
Needed to make sure that deleted labels/aliases are actually deleted
in the index.
Bug: T166589
Change-Id: I6851a5f58716267f312801b1a6e91388e474d8fa
Depends-On: Idc4ae06f76d0e70eaee7e84212cd19e2282a6fb9
---
M repo/includes/Search/Elastic/Fields/LabelsField.php
M repo/tests/phpunit/includes/Search/Elastic/Fields/LabelsFieldTest.php
2 files changed, 20 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/58/360358/1
diff --git a/repo/includes/Search/Elastic/Fields/LabelsField.php
b/repo/includes/Search/Elastic/Fields/LabelsField.php
index e9d3716..5b66cd9 100644
--- a/repo/includes/Search/Elastic/Fields/LabelsField.php
+++ b/repo/includes/Search/Elastic/Fields/LabelsField.php
@@ -82,4 +82,14 @@
return $data;
}
+ public function getEngineHints() {
+ if ( class_exists( \CirrusSearch\Search\CirrusIndexField::class
) ) {
+ // Needed because the default update strategy is merge
fields
+ // In the case of multilanguage field we always send
the full list
+ // of language so we force the equals handler.
+ // Not setting this will lead labels not being deleted
from the index.
+ return [
\CirrusSearch\Search\CirrusIndexField::NOOP_HINT => "equals" ];
+ }
+ return [];
+ }
}
diff --git
a/repo/tests/phpunit/includes/Search/Elastic/Fields/LabelsFieldTest.php
b/repo/tests/phpunit/includes/Search/Elastic/Fields/LabelsFieldTest.php
index c71ff07..f404371 100644
--- a/repo/tests/phpunit/includes/Search/Elastic/Fields/LabelsFieldTest.php
+++ b/repo/tests/phpunit/includes/Search/Elastic/Fields/LabelsFieldTest.php
@@ -88,4 +88,14 @@
$this->assertSame( [], $labels->getMapping( $searchEngine ) );
}
+ public function testHints() {
+ $labels = new LabelsField( [ 'en', 'es', 'ru', 'de' ] );
+ if ( !class_exists( CirrusSearch::class ) ) {
+ $this->assertEquals( [], $labels->getEngineHints() );
+ } else {
+ $this->assertEquals( [ 'noop' => 'equals' ],
$labels->getEngineHints() );
+ }
+ }
+
+
}
--
To view, visit https://gerrit.wikimedia.org/r/360358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6851a5f58716267f312801b1a6e91388e474d8fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits