[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Dont generate pointless remove script on reindex

2017-07-10 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/363733 )

Change subject: Dont generate pointless remove script on reindex
..


Dont generate pointless remove script on reindex

When reindexing we have a special flag for removing unused fields from
the index. If this flag is not provided we end up generating a list
of [''], which generates the script:

ctx._source.remove('');

This is pointless, so filter out empty strings before generating
the script.

Change-Id: I1a61e361d35d2fa6bac5977d3bab55c9c954f297
---
M includes/Maintenance/Reindexer.php
M maintenance/updateOneSearchIndexConfig.php
2 files changed, 9 insertions(+), 3 deletions(-)

Approvals:
  Smalyshev: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Maintenance/Reindexer.php 
b/includes/Maintenance/Reindexer.php
index 625772d..bae65de 100644
--- a/includes/Maintenance/Reindexer.php
+++ b/includes/Maintenance/Reindexer.php
@@ -380,8 +380,13 @@
'lang' => 'painless',
];
foreach ( $this->fieldsToDelete as $field ) {
-   // Does this actually work?
-   $script['inline'] .= "ctx._source.remove('$field');";
+   $field = trim( $field );
+   if ( strlen( $field ) ) {
+   $script['inline'] .= 
"ctx._source.remove('$field');";
+   }
+   }
+   if ( $script['inline'] === '' ) {
+   return null;
}
 
return $script;
diff --git a/maintenance/updateOneSearchIndexConfig.php 
b/maintenance/updateOneSearchIndexConfig.php
index 21a23c7..c42dfe8 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -407,6 +407,7 @@
private function validateSpecificAlias() {
$connection = $this->getConnection();
 
+   $fieldsToDeleteString = $this->getOption( 'fieldsToDelete', '' 
);
$reindexer = new Reindexer(
$this->getSearchConfig(),
$connection,
@@ -417,7 +418,7 @@
$this->getReplicaCount(),
$this->getMergeSettings(),
$this,
-   explode( ',', $this->getOption( 'fieldsToDelete', '' ) )
+   array_filter( explode( ',', $this->getOption( 
'fieldsToDelete', '' ) ) )
);
 
$validator = new 
\CirrusSearch\Maintenance\Validators\SpecificAliasValidator(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a61e361d35d2fa6bac5977d3bab55c9c954f297
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson 
Gerrit-Reviewer: Smalyshev 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Dont generate pointless remove script on reindex

2017-07-06 Thread EBernhardson (Code Review)
EBernhardson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/363733 )

Change subject: Dont generate pointless remove script on reindex
..

Dont generate pointless remove script on reindex

When reindexing we have a special flag for removing unused fields from
the index. If this flag is not provided we end up generating a list
of [''], which generates the script:

ctx._source.remove('');

This is pointless, so filter out empty strings before generating
the script.

Change-Id: I1a61e361d35d2fa6bac5977d3bab55c9c954f297
---
M includes/Maintenance/Reindexer.php
M maintenance/updateOneSearchIndexConfig.php
2 files changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/33/363733/1

diff --git a/includes/Maintenance/Reindexer.php 
b/includes/Maintenance/Reindexer.php
index 616afbc..7346489 100644
--- a/includes/Maintenance/Reindexer.php
+++ b/includes/Maintenance/Reindexer.php
@@ -380,8 +380,13 @@
'lang' => 'painless',
];
foreach ( $this->fieldsToDelete as $field ) {
-   // Does this actually work?
-   $script['inline'] .= "ctx._source.remove('$field');";
+   $field = trim( $field );
+   if ( strlen( $field ) ) {
+   $script['inline'] .= 
"ctx._source.remove('$field');";
+   }
+   }
+   if ( $script['inline'] === '' ) {
+   return null;
}
 
return $script;
diff --git a/maintenance/updateOneSearchIndexConfig.php 
b/maintenance/updateOneSearchIndexConfig.php
index 21a23c7..c42dfe8 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -407,6 +407,7 @@
private function validateSpecificAlias() {
$connection = $this->getConnection();
 
+   $fieldsToDeleteString = $this->getOption( 'fieldsToDelete', '' 
);
$reindexer = new Reindexer(
$this->getSearchConfig(),
$connection,
@@ -417,7 +418,7 @@
$this->getReplicaCount(),
$this->getMergeSettings(),
$this,
-   explode( ',', $this->getOption( 'fieldsToDelete', '' ) )
+   array_filter( explode( ',', $this->getOption( 
'fieldsToDelete', '' ) ) )
);
 
$validator = new 
\CirrusSearch\Maintenance\Validators\SpecificAliasValidator(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a61e361d35d2fa6bac5977d3bab55c9c954f297
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson 

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