Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179923

Change subject: Break 2 mappingconfigbuilder arguments out of constructor
......................................................................

Break 2 mappingconfigbuilder arguments out of constructor

Change-Id: I9166e2fbfdc124e703671e853d22918bec89caad
---
M includes/Maintenance/MappingConfigBuilder.php
M includes/Maintenance/Reindexer.php
M maintenance/updateOneSearchIndexConfig.php
3 files changed, 15 insertions(+), 33 deletions(-)


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

diff --git a/includes/Maintenance/MappingConfigBuilder.php 
b/includes/Maintenance/MappingConfigBuilder.php
index fa7c6f5..69444b3 100644
--- a/includes/Maintenance/MappingConfigBuilder.php
+++ b/includes/Maintenance/MappingConfigBuilder.php
@@ -47,39 +47,25 @@
        const VERSION = '1.9';
 
        /**
-        * Whether to allow prefix searches to match on any word
-        * @var bool
-        */
-       private $prefixSearchStartsWithAnyWord;
-
-       /**
-        * Whether phrase searches should use the suggestion analyzer
-        * @var bool
-        */
-       private $phraseSuggestUseText;
-
-       /**
         * @var bool should the index be optimized for the experimental 
highlighter?
         */
        private $optimizeForExperimentalHighlighter;
 
        /**
         * Constructor
-        * @param bool $anyWord Prefix search on any word
-        * @param bool $useText Text uses suggestion analyzer
-        * @param bool should the index be optimized for the experimental 
highlighter?
+        * @param bool $optimizeForExperimentalHighlighter should the index be 
optimized for the experimental highlighter?
         */
-       public function __construct( $anyWord, $phraseSuggestUseText, 
$optimizeForExperimentalHighlighter ) {
-               $this->prefixSearchStartsWithAnyWord = $anyWord;
-               $this->phraseSuggestUseText = $phraseSuggestUseText;
+       public function __construct( $optimizeForExperimentalHighlighter ) {
                $this->optimizeForExperimentalHighlighter = 
$optimizeForExperimentalHighlighter;
        }
 
        /**
         * Build the mapping config.
+        * @param bool $prefixSearchStartsWithAnyWord Prefix search on any word
+        * @param bool $phraseSuggestUseText Text uses suggestion analyzer
         * @return array the mapping config
         */
-       public function buildConfig() {
+       public function buildConfig( $prefixSearchStartsWithAnyWord, 
$phraseSuggestUseText ) {
                global $wgCirrusSearchAllFields,
                        $wgCirrusSearchWeights,
                        $wgCirrusSearchWikimediaExtraPlugin;
@@ -95,7 +81,7 @@
                        array( 'analyzer' => 'near_match_asciifolding', 
'index_options' => 'docs' ),
                        array( 'analyzer' => 'keyword', 'index_options' => 
'docs' ),
                );
-               if ( $this->prefixSearchStartsWithAnyWord ) {
+               if ( $prefixSearchStartsWithAnyWord ) {
                        $titleExtraAnalyzers[] = array(
                                'index_analyzer' => 'word_prefix',
                                'search_analyzer' => 'plain_search',
@@ -113,7 +99,7 @@
 
                $textExtraAnalyzers = array();
                $textOptions = MappingConfigBuilder::ENABLE_NORMS | 
MappingConfigBuilder::SPEED_UP_HIGHLIGHTING;
-               if ( $this->phraseSuggestUseText ) {
+               if ( $phraseSuggestUseText ) {
                        $textExtraAnalyzers[] = $suggestExtra;
                        $textOptions |= MappingConfigBuilder::COPY_TO_SUGGEST;
                }
diff --git a/includes/Maintenance/Reindexer.php 
b/includes/Maintenance/Reindexer.php
index 7b5bb48..3467cb2 100644
--- a/includes/Maintenance/Reindexer.php
+++ b/includes/Maintenance/Reindexer.php
@@ -77,7 +77,7 @@
        private $mergeSettings;
 
        /**
-        * @var MappingConfigBuilder
+        * @var array
         */
        private $mappingConfig;
 
@@ -100,10 +100,10 @@
         * @param string $replicaCount
         * @param int $connectionTimeout
         * @param array $mergeSettings
-        * @param MappingConfigBuilder $mappingConfig
+        * @param array $mappingConfig
         * @param Maintenance $out
         */
-       public function __construct( Index $index, \ElasticaConnection 
$connection, Type $type, Type $oldType, $shardCount, $replicaCount, 
$connectionTimeout, array $mergeSettings, MappingConfigBuilder $mappingConfig, 
Maintenance $out = null ) {
+       public function __construct( Index $index, \ElasticaConnection 
$connection, Type $type, Type $oldType, $shardCount, $replicaCount, 
$connectionTimeout, array $mergeSettings, array $mappingConfig, Maintenance 
$out = null ) {
                // @todo: this constructor has too many arguments - refactor!
                $this->index = $index;
                $this->client = $this->index->getClient();
@@ -254,8 +254,7 @@
                                'lang' => 'groovy'
                        ) );
                }
-               $pageProperties = $this->mappingConfig->buildConfig();
-               $pageProperties = $pageProperties[ 'page' ][ 'properties' ];
+               $pageProperties = $this->mappingConfig['page']['properties'];
                try {
                        $query = new Query();
                        $query->setFields( array( '_id', '_source' ) );
diff --git a/maintenance/updateOneSearchIndexConfig.php 
b/maintenance/updateOneSearchIndexConfig.php
index 38ec561..2b8df13 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -370,7 +370,7 @@
                        $this->getIndex(),
                        $this->optimizeIndexForExperimentalHighlighter,
                        $this->availablePlugins,
-                       $this->getMappingConfig()->buildConfig(),
+                       $this->getMappingConfig(),
                        $this->getPageType(),
                        $this->getNamespaceType(),
                        $this
@@ -517,14 +517,11 @@
        }
 
        /**
-        * @return MappingConfigBuilder
+        * @return array
         */
        protected function getMappingConfig() {
-               return new MappingConfigBuilder(
-                       $this->prefixSearchStartsWithAny,
-                       $this->phraseSuggestUseText,
-                       $this->optimizeIndexForExperimentalHighlighter
-               );
+               $builder = new MappingConfigBuilder( 
$this->optimizeIndexForExperimentalHighlighter );
+               return $builder->buildConfig( $this->prefixSearchStartsWithAny, 
$this->phraseSuggestUseText );
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9166e2fbfdc124e703671e853d22918bec89caad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to