DCausse has uploaded a new change for review.

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

Change subject: [WIP] Generalize mw_cirrus_versions into a multi-purpose meta 
index
......................................................................

[WIP] Generalize mw_cirrus_versions into a multi-purpose meta index

Create and maintain a mw_cirrus_metastore index per cluste.
This index will be used for :
- versions
- frozen indices
- tracking sanitize offsets

WIP: add a new maint script to create the index

Bug: T133793
Change-Id: Ib44b3e71a68daf2e5216fbf250a7fd1bd90812f9
---
M autoload.php
M includes/Connection.php
M includes/Maintenance/ConfigUtils.php
A includes/Maintenance/MetaStoreIndex.php
M maintenance/checkIndexes.php
M maintenance/updateSuggesterIndex.php
M maintenance/updateVersionIndex.php
7 files changed, 482 insertions(+), 65 deletions(-)


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

diff --git a/autoload.php b/autoload.php
index c81556c..342b852 100644
--- a/autoload.php
+++ b/autoload.php
@@ -61,6 +61,7 @@
        'CirrusSearch\\Maintenance\\IndexNamespaces' => __DIR__ . 
'/maintenance/indexNamespaces.php',
        'CirrusSearch\\Maintenance\\Maintenance' => __DIR__ . 
'/includes/Maintenance/Maintenance.php',
        'CirrusSearch\\Maintenance\\MappingConfigBuilder' => __DIR__ . 
'/includes/Maintenance/MappingConfigBuilder.php',
+       'CirrusSearch\\Maintenance\\MetaStoreIndex' => __DIR__ . 
'/includes/Maintenance/MetaStoreIndex.php',
        'CirrusSearch\\Maintenance\\OrderedStreamingForkController' => __DIR__ 
. '/includes/Maintenance/OrderedStreamingForkController.php',
        'CirrusSearch\\Maintenance\\Reindexer' => __DIR__ . 
'/includes/Maintenance/Reindexer.php',
        'CirrusSearch\\Maintenance\\RunSearch' => __DIR__ . 
'/maintenance/runSearch.php',
diff --git a/includes/Connection.php b/includes/Connection.php
index 461eb86..f4ad8a7 100644
--- a/includes/Connection.php
+++ b/includes/Connection.php
@@ -4,6 +4,7 @@
 
 use ElasticaConnection;
 use MWNamespace;
+use CirrusSearch\Maintenance\MetaStoreIndex;
 
 /**
  * Forms and caches connection to Elasticsearch as well as client objects
@@ -189,31 +190,10 @@
        }
 
        /**
-        * Fetch the Elastica Type used for all wikis in the cluster to track
-        * frozen indexes that should not be written to.
-        * @return \Elastica\Index
-        */
-       public function getFrozenIndex() {
-               global $wgCirrusSearchCreateFrozenIndex;
-
-               $index = $this->getIndex( 
'mediawiki_cirrussearch_frozen_indexes' );
-               if ( $wgCirrusSearchCreateFrozenIndex ) {
-                       if ( !$index->exists() ) {
-                               $options = array(
-                                       'number_of_shards' => 1,
-                                       'auto_expand_replicas' => '0-2',
-                                );
-                               $index->create( $options, true );
-                       }
-               }
-               return $index;
-       }
-
-       /**
         * @return \Elastica\Type
         */
        public function getFrozenIndexNameType() {
-               return $this->getFrozenIndex()->getType( 'name' );
+               return MetaStoreIndex::getFrozenType( $this );
        }
 
        /**
diff --git a/includes/Maintenance/ConfigUtils.php 
b/includes/Maintenance/ConfigUtils.php
index cf5fd16..4ef138d 100644
--- a/includes/Maintenance/ConfigUtils.php
+++ b/includes/Maintenance/ConfigUtils.php
@@ -115,27 +115,36 @@
        }
 
        /**
+        * @param string $what
+        * @return string[] list of modules or plugins
+        */
+       private function scanModulesOrPlugins( $what ) {
+               $result = $this->client->request( '_nodes' );
+               $result = $result->getData();
+               $availables = array();
+               $first = true;
+               foreach ( array_values( $result[ 'nodes' ] ) as $node ) {
+                       $plugins = array();
+                       foreach ( $node[ $what ] as $plugin ) {
+                               $plugins[] = $plugin[ 'name' ];
+                       }
+                       if ( $first ) {
+                               $availables = $plugins;
+                               $first = false;
+                       } else {
+                               $availables = array_intersect( $availables, 
$plugins );
+                       }
+               }
+               return $availables;
+       }
+
+       /**
         * @param string[] $bannedPlugins
         * @return string[]
         */
        public function scanAvailablePlugins( array $bannedPlugins = array() ) {
                $this->outputIndented( "Scanning available plugins..." );
-               $result = $this->client->request( '_nodes' );
-               $result = $result->getData();
-               $availablePlugins = array();
-               $first = true;
-               foreach ( array_values( $result[ 'nodes' ] ) as $node ) {
-                       $plugins = array();
-                       foreach ( $node[ 'plugins' ] as $plugin ) {
-                               $plugins[] = $plugin[ 'name' ];
-                       }
-                       if ( $first ) {
-                               $availablePlugins = $plugins;
-                               $first = false;
-                       } else {
-                               $availablePlugins = array_intersect( 
$availablePlugins, $plugins );
-                       }
-               }
+               $availablePlugins = $this->scanModulesOrPlugins( 'plugins' );
                if ( count( $availablePlugins ) === 0 ) {
                        $this->output( 'none' );
                }
@@ -151,6 +160,27 @@
                return $availablePlugins;
        }
 
+       /**
+        * @param string[] $bannedPlugins
+        * @return string[]
+        */
+       public function scanAvailableModules() {
+               $this->outputIndented( "Scanning available modules..." );
+               $result = $this->client->request( '_nodes' );
+               $result = $result->getData();
+               $availableModules = $this->scanModulesOrPlugins( 'modules' );
+               if ( count( $availableModules ) === 0 ) {
+                       $this->output( 'none' );
+               }
+               $this->output( "\n" );
+               foreach ( array_chunk( $availableModules, 5 ) as $moduleChunk ) 
{
+                       $modules = implode( ', ', $moduleChunk );
+                       $this->outputIndented( "\t$modules\n" );
+               }
+
+               return $availableModules;
+       }
+
        // @todo: bring below options together in some abstract class where 
Validator & Reindexer also extend from
 
        /**
diff --git a/includes/Maintenance/MetaStoreIndex.php 
b/includes/Maintenance/MetaStoreIndex.php
new file mode 100644
index 0000000..0e43b6f
--- /dev/null
+++ b/includes/Maintenance/MetaStoreIndex.php
@@ -0,0 +1,422 @@
+<?php
+
+namespace CirrusSearch\Maintenance;
+use CirrusSearch\Connection;
+
+use Elastica\Client;
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/**
+ * Utility class to manage a multipurpose metadata storage index for cirrus.
+ */
+class MetaStoreIndex {
+       /**
+        * @const int version of the
+        */
+       const METASTORE_VERSION = 1;
+       /**
+        * @const string index name
+        */
+       const INDEX_NAME = 'mw_cirrus_metastore';
+
+       /**
+        * @const string previous index name (bc code)
+        */
+       const OLD_INDEX_NAME = 'mw_cirrus_versions';
+
+       /**
+        * @const string type for storing version tracking info
+        */
+       const VERSION_TYPE = 'version';
+
+       /**
+        * @const string type for storing sanitze jobs tracking info
+        */
+       const SANITIZE_TYPE = 'sanitize';
+
+       /**
+        * @const string type for storing frozen indices tracking info
+        */
+       const FROZEN_TYPE = 'frozen';
+
+       /**
+        * @const string type for storing internal data
+        */
+       const INTERNAL_TYPE = 'internal';
+
+       /**
+        * @var Connection
+        */
+       private $connection;
+
+       /**
+        * @var \Elastica\Client
+        */
+       private $client;
+
+       /**
+        * @var Maintenance|null initiator maintenance script
+       */
+       private $out;
+
+       /**
+        * @var string master operation timeout
+        */
+       private $masterTimeout;
+
+       /**
+        * @var ConfigUtils
+        */
+       private $configUtils;
+
+       /**
+        * @param Connection $connection
+        * @param Maintenance $out
+        * @param $masterTimeout int
+        */
+       public function __construct( Connection $connection, Maintenance $out, 
$masterTimeout = '10000s' ) {
+               $this->connection = $connection;
+               $this->client = $connection->getClient();
+               $this->configUtils = new ConfigUtils( $this->client, $out );
+               $this->out = $out;
+               $this->masterTimeout = $masterTimeout;
+       }
+
+       public function createOrUpdateIndex() {
+               $this->fixOldName();
+               $status = $this->client->getStatus();
+               // If the mw_cirrus_metastore alias still not exists it
+               // means we need to create everything from scratch.
+               if ( !$status->aliasExists( self::INDEX_NAME ) ) {
+                       $this->log( self::INDEX_NAME . " missing creating.\n" );
+                       $newIndex = $this->createIndex();
+                       $this->switchAliasTo( $newIndex );
+               } else {
+                       $version = $this->getMetastoreVersion();
+                       if ( $version < self::METASTORE_VERSION ) {
+                               $this->log( self::INDEX_NAME . " version 
mismatch upgrading.\n" );
+                               $this->upgradeMetastore();
+                       } elseif ( $version > self::METASTORE_VERSION ) {
+                               throw new \Exception( "Metastore version 
$version found, cannot upgrade to a lower version: " . self::METASTORE_VERSION 
);
+                       }
+               }
+       }
+
+       /**
+        * Create a new metastore index.
+        * @param string $suffix index suffix
+        * @return \Elastica\Index the newly created index
+        */
+       public function createNewIndex( $suffix = 'first' ) {
+               // @todo: add support mapping/settings changes with index 
versionning
+               // possibly by using the reindex plugin
+               $name = self::INDEX_NAME . '_' . $suffix;
+               $this->log( "Creating metastore index... $name" );
+               // Don't forget to update METASTORE_VERSION when changing 
something
+               // in the settings/mappings
+               $settings = array(
+                       'number_of_shards' => 1,
+                       'auto_expand_replicas' => '0-2'
+               );
+               $mappings = array(
+                       self::VERSION_TYPE => array(
+                               'properties' => array(
+                                       'analysis_maj' => array( 'type' => 
'long', 'include_in_all' => false ),
+                                       'analysis_min' => array( 'type' => 
'long', 'include_in_all' => false ),
+                                       'mapping_maj' => array( 'type' => 
'long', 'include_in_all' => false ),
+                                       'mapping_min' => array( 'type' => 
'long', 'include_in_all' => false ),
+                                       'shard_count' => array( 'type' => 
'long', 'include_in_all' => false ),
+                               ),
+                       ),
+                       self::FROZEN_TYPE => array(
+                               'properties' => array(),
+                       ),
+                       self::SANITIZE_TYPE => array(
+                               'properties' => array(),
+                       ),
+                       self::INTERNAL_TYPE => array(
+                               'properties' => array(
+                                       'version' => array(
+                                               'type' => 'integer'
+                                       ),
+                               ),
+                       ),
+               );
+               $args = array(
+                       'settings' => $settings,
+                       'mappings' => $mappings,
+               );
+               // @todo utilize $this->getIndex()->create(...) once it 
supports setting
+               // the master_timeout parameter.
+               $index = $this->client->getIndex( $name );
+               $index->request(
+                       '',
+                       \Elastica\Request::PUT,
+                       $args,
+                       array( 'master_timeout' => $this->masterTimeout )
+               );
+               $this->log( " ok\n" );
+               $this->configUtils->waitForGreen( $index->getName(), 3600 );
+               $this->storeMetastoreVersion( $index );
+               return $index;
+       }
+
+       /**
+        * Switch the mw_cirrus_metastore alias to this new index name.
+        * @param \Elastica\Index $index
+        */
+       private function switchAliasTo( $index ) {
+               $name = $index->getName();
+               $oldIndexName = $this->getAliasedIndexName();
+               if ( $oldIndexName !== null ) {
+                       $this->log( "Switching " . self::INDEX_NAME . " alias 
from $oldIndexName to $name.\n" );
+               } else {
+                       $this->log( "Creating " . self::INDEX_NAME . " alias to 
$name.\n" );
+               }
+
+               if ( $oldIndexName == $name ) {
+                       throw new \Exception( "Cannot switch aliases old and 
new index names are identical: $name" );
+               }
+               // Create the alias
+               $path = '_aliases';
+               $data = array( 'actions' => array(
+                       array(
+                               'add' => array(
+                                       'index' => $name,
+                                       'alias' => self::INDEX_NAME,
+                               )
+                       ),
+               ) );
+               if ( $oldIndexName !== null ) {
+                       $data['actions'][] = array(
+                                       'remove' => array(
+                                               'index' => $oldIndexName,
+                                               'alias' => self::INDEX_NAME,
+                                       )
+                               );
+               }
+               $this->client->request( $path, \Elastica\Request::POST, $data,
+                       array( 'master_timeout' => $this->masterTimeout ) );
+               if ( $oldIndexName !== null ) {
+                       $this->log( "Deleting old index $oldIndexName\n" );
+                       $this->connection->getIndex( $oldIndexName )->delete();
+               }
+       }
+
+       /**
+        * @return string the current index behind the self::INDEX_NAME alias
+        */
+       private function getAliasedIndexName() {
+               $resp = $this->client->request( '_aliases/' . self::INDEX_NAME, 
\Elastica\Request::GET, array() );
+               $indexName = null;
+               foreach( $resp->getData() as $index => $aliases ) {
+                       if ( isset( $aliases['aliases'][self::INDEX_NAME] ) ) {
+                               if ( $indexName !== null ) {
+                                       throw new Exception( "Multiple indices 
are aliased with " . self::INDEX_NAME . ", please fix manually." );
+                               }
+                               $indexName = $index;
+                       }
+               }
+               return $indexName;
+       }
+
+
+       private function upgradeMetastore() {
+               $plugins = $this->configUtils->scanAvailableModules();
+               if ( !array_search( 'reindex', $plugins ) ) {
+                       throw new \Exception( "The reindex module is mandatory 
to upgrade the metastore" );
+               }
+               $index = $this->createNewIndex( (string) time() );
+               $reindex = array(
+                       'source' => array ( 'index' => self::INDEX_NAME ),
+                       'dest' => array( 'index' => $index->getName() ),
+               );
+               // reindex is extremely fast so we can wait for it
+               // we might consider using the task manager if this process
+               // becomes longer and/or prone to curl timeouts
+               $resp = $this->client->request( '_reindex',
+                       \Elastica\Request::POST,
+                       $reindex,
+                       array( 'wait_for_completion' => true )
+               );
+               $index->refresh();
+               // Store the metastore version again the reindex process may
+               // have overwritten it with a previous version
+               $this->storeMetastoreVersion( $index );
+               $this->switchAliasTo( $index );
+       }
+
+       /**
+        * BC strategy to reuse mw_cirrus_versions as the new 
mw_cirrus_metastore
+        * If mw_cirrus_versions exists with no mw_cirrus_metastore
+        */
+       private function fixOldName() {
+               $status = $this->client->getStatus();
+               if ( !$status->indexExists( self::OLD_INDEX_NAME ) ) {
+                       return;
+               }
+               // Old mw_cirrus_versions exists, if mw_cirrus_metastore alias 
does not
+               // exist we must create it
+               if ( !$status->aliasExists( self::INDEX_NAME ) ) {
+                       $this->log( "Adding transition alias to " . 
self::OLD_INDEX_NAME . "\n" );
+                       // Old one exists but new one does not
+                       // we need to create an alias
+                       $index = $this->client->getIndex( self::OLD_INDEX_NAME 
);
+                       $path = '_aliases';
+                       $data = array( 'actions' => array( array(
+                               'add' => array(
+                                       'index' => self::OLD_INDEX_NAME,
+                                       'alias' => self::INDEX_NAME,
+                               ) ),
+                       ) );
+                       $this->client->request( $path, \Elastica\Request::POST, 
$data,
+                               array( 'master_timeout' => $this->masterTimeout 
) );
+                       // The version check should schedule a reindex
+               }
+       }
+
+       /**
+        * @return int
+        */
+       public function getMetastoreVersion() {
+               try {
+                       $doc = $this->internalType()->getDocument( 'version' );
+               } catch ( \Elastica\Exception\NotFoundException $e ) {
+                       return -1;
+               }
+               return (int) $doc->get('version');
+       }
+
+       /**
+        * @param \Elastica\Index $index new index
+        */
+       private function storeMetastoreVersion( $index ) {
+               $index->getType( self::INTERNAL_TYPE )->addDocument(
+                       new \Elastica\Document(
+                               'version',
+                               array( 'version' => self::METASTORE_VERSION )
+                       )
+               );
+       }
+
+       /**
+        * @param string $msg log message
+        */
+       private function log( $msg ) {
+               if ($this->out ) {
+                       $this->out->output( $msg );
+               }
+       }
+
+       /**
+        * Get the version tracking index type
+        * @return \Elastica\Type
+        */
+       public function versionType() {
+               return self::getVersionType( $this->connection );
+       }
+
+       /**
+        * Get the frozen indices tracking index type
+        * @return \Elastica\Type $type
+        */
+       public function frozenType() {
+               return self::getFrozenType( $this->connection );
+       }
+
+       /**
+        * Get the sanitize tracking index type
+        * @return \Elastica\Type $type
+        */
+       public function sanitizeType() {
+               return self::getSanitizeType( $this->connection );
+       }
+
+       /**
+        * Get the internal index type
+        * @return \Elastica\Type $type
+        */
+       public function internalType() {
+               return self::getInternalType( $this->connection );
+       }
+
+       /**
+        * Get the version tracking index type
+        * @param Connection $connection
+        * @return \Elastica\Type $type
+        */
+       public static function getVersionType( Connection $connection ) {
+               if ( !$connection->getIndex( self::INDEX_NAME )->exists() ) {
+                       // @todo: remove BC code
+                       return $connection->getIndex( 'mw_cirrus_versions' 
)->getType( 'version' );
+               }
+               return $connection->getIndex( self::INDEX_NAME )->getType( 
self::VERSION_TYPE );
+       }
+
+       /**
+        * Get the sanitize tracking index type
+        * @param Connection $connection
+        * @return \Elastica\Type $type
+        */
+       public static function getSanitizeType( Connection $connection ) {
+               return $connection->getIndex( self::INDEX_NAME )->getType( 
self::SANITIZE_TYPE );
+       }
+
+       /**
+        * Get the frozen indices tracking index type
+        * @param Connection $connection
+        * @return \Elastica\Type $type
+        */
+       public static function getFrozenType( Connection $connection ) {
+               // @todo: use
+               // return $connection->getIndex( self::INDEX_NAME )->getType( 
self::FROZEN_TYPE );
+               // when mw_cirrus_metastore is up
+               global $wgCirrusSearchCreateFrozenIndex;
+               $index = $connection->getIndex( 
'mediawiki_cirrussearch_frozen_indexes' );
+               if ( $wgCirrusSearchCreateFrozenIndex ) {
+                       if ( !$index->exists() ) {
+                               $options = array(
+                                       'number_of_shards' => 1,
+                                       'auto_expand_replicas' => '0-2',
+                                );
+                               $index->create( $options, true );
+                       }
+               }
+               return $index->getType( 'name' );
+       }
+
+       /**
+        * Get the sanitize tracking index type
+        * @param Connection $connection
+        * @return \Elastica\Type $type
+        */
+       private static function getInternalType( Connection $connection ) {
+               return $connection->getIndex( self::INDEX_NAME )->getType( 
self::INTERNAL_TYPE );
+       }
+
+       /**
+        * Check if cirrus is ready by checking if some indices have been 
created on this cluster
+        * @param Connection $connection
+        * @return bool
+        */
+       public static function cirrusReady( Connection $connection ) {
+               return $connection->getIndex( self::INDEX_NAME )->exists() ||
+                       $connection->getIndex( self::OLD_INDEX_NAME )->exists();
+       }
+}
diff --git a/maintenance/checkIndexes.php b/maintenance/checkIndexes.php
index 59d060c..2a601e3 100644
--- a/maintenance/checkIndexes.php
+++ b/maintenance/checkIndexes.php
@@ -63,6 +63,7 @@
                }
                $this->ensureClusterStateFetched();
                $this->ensureCirrusInfoFetched();
+               // @todo: use MetaStoreIndex
                $this->checkIndex( 'mw_cirrus_versions', 1 );
                $aliases = array();
                foreach ( $this->clusterState[ 'metadata' ][ 'indices' ] as 
$indexName => $data ) {
diff --git a/maintenance/updateSuggesterIndex.php 
b/maintenance/updateSuggesterIndex.php
index 2863e16..6dd4704 100644
--- a/maintenance/updateSuggesterIndex.php
+++ b/maintenance/updateSuggesterIndex.php
@@ -223,9 +223,8 @@
 
                try {
                        // If the version does not exist it's certainly because 
nothing has been indexed.
-                       $versionIndex = $this->getConnection()->getIndex( 
'mw_cirrus_versions' );
-                       if ( !$versionIndex->exists() ) {
-                               throw new \Exception("mw_cirrus_versions does 
not exist, you must index your data first");
+                       if ( !MetaStoreIndex::cirrusReady( 
$this->getConnection() ) ) {
+                               throw new \Exception("Cirrus meta sotre does 
not exist, you must index your data first");
                        }
 
                        if ( !$this->canWrite() ) {
@@ -348,9 +347,9 @@
                list( $aMaj ) = explode( '.', 
\CirrusSearch\Maintenance\SuggesterAnalysisConfigBuilder::VERSION );
 
                try {
-                       $versionDoc = $this->getConnection()->getIndex( 
'mw_cirrus_versions' )->getType( 'version' )->getDocument( 
$this->getIndexTypeName() );
+                       $versionDoc = MetaStoreIndex::getVersionType( 
$this->getConnection() )->getDocument( $this->getIndexTypeName() );
                } catch( \Elastica\Exception\NotFoundException $nfe ) {
-                       $this->error( 'Index missing in mw_cirrus_versions, 
cannot recycle.' );
+                       $this->error( 'Index missing in 
mw_cirrus_metastore::version, cannot recycle.' );
                        return false;
                }
 
@@ -748,9 +747,9 @@
 
        private function updateVersions() {
                $this->log( "Updating tracking indexes..." );
-               $index = $this->getConnection()->getIndex( 'mw_cirrus_versions' 
);
+               $index = MetaStoreIndex::getVersionType( $this->getConnection() 
);
                if ( !$index->exists() ) {
-                       throw new \Exception("mw_cirrus_versions does not 
exist, you must index your data first");
+                       throw new \Exception("meta store does not exist, you 
must index your data first");
                }
                list( $aMaj, $aMin ) = explode( '.', 
\CirrusSearch\Maintenance\SuggesterAnalysisConfigBuilder::VERSION );
                list( $mMaj, $mMin ) = explode( '.', 
\CirrusSearch\Maintenance\SuggesterMappingConfigBuilder::VERSION );
diff --git a/maintenance/updateVersionIndex.php 
b/maintenance/updateVersionIndex.php
index 7a6cb2d..1c65a45 100644
--- a/maintenance/updateVersionIndex.php
+++ b/maintenance/updateVersionIndex.php
@@ -65,7 +65,7 @@
                }
                // WHAT ARE YOU DOING TRACKING MORE THAN 5000 INDEXES?!?
                $query->setSize( 5000 );
-               $res = $this->getType()->getIndex()->search( $query );
+               $res = $this->getType()->search( $query );
                foreach( $res as $r ) {
                        $data = $r->getData();
                        $this->outputIndented( "index name: " . $r->getId() . 
"\n" );
@@ -105,25 +105,9 @@
         * @return \Elastica\Type
         */
        private function getType() {
-               $index = $this->getConnection()->getIndex( 'mw_cirrus_versions' 
);
-               if ( !$index->exists() ) {
-                       $this->outputIndented( "Creating tracking index..." );
-                       $index->create( array( 'number_of_shards' => 1,
-                               'auto_expand_replicas' => '0-2', ), true );
-                       $mapping = new \Elastica\Type\Mapping();
-                       $mapping->setType( $index->getType( 'version' ) );
-                       $mapping->setProperties( array(
-                               'analysis_maj' => array( 'type' => 'long', 
'include_in_all' => false ),
-                               'analysis_min' => array( 'type' => 'long', 
'include_in_all' => false ),
-                               'mapping_maj' => array( 'type' => 'long', 
'include_in_all' => false ),
-                               'mapping_min' => array( 'type' => 'long', 
'include_in_all' => false ),
-                               'shard_count' => array( 'type' => 'long', 
'include_in_all' => false ),
-                       ) );
-                       $mapping->send();
-                       $this->output( "done\n" );
-               }
-
-               return $index->getType( 'version' );
+               $metaStore = new MetaStoreIndex( $this->getConnection(), $this 
);
+               $metaStore->createOrUpdateIndex();
+               return $metaStore->versionType();
        }
 }
 

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

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

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

Reply via email to