DCausse has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/343082 )

Change subject: Use the _aliases endpoint for fast index names retrieval
......................................................................

Use the _aliases endpoint for fast index names retrieval

When calling Cluster::getIndexNames() Elastica appears to fetch
unneeded information from the cluster. This results in a slow query
when this extension is used with a cluster that has many indices.
Use the _aliases API endpoint with wildcard expansion to speed-up this
process.

Bug: T160584
Change-Id: I506862c1ed4729103f76417b85cdc9b0773cd3f2
---
M ApiFeatureUsageQueryEngineElastica.php
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApiFeatureUsage 
refs/changes/82/343082/1

diff --git a/ApiFeatureUsageQueryEngineElastica.php 
b/ApiFeatureUsageQueryEngineElastica.php
index a2fabd0..d4ac880 100644
--- a/ApiFeatureUsageQueryEngineElastica.php
+++ b/ApiFeatureUsageQueryEngineElastica.php
@@ -39,7 +39,17 @@
 
        protected function getIndexNames() {
                if ( !$this->indexNames ) {
-                       $this->indexNames = 
$this->getClient()->getCluster()->getIndexNames();
+                       $response = $this->getClient()->request(
+                               urlencode( $this->options['indexPrefix'] ) + 
'*/_aliases'
+                       );
+                       if ( $response->isOK() ) {
+                               $this->indexNames = array_keys( 
$response->getData() );
+                       } else {
+                               throw new MWException( __METHOD__ .
+                                       ': Cannot fetch index names from 
elasticsearch: ' .
+                                       $response->getError()
+                               );
+                       }
                }
                return $this->indexNames;
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I506862c1ed4729103f76417b85cdc9b0773cd3f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ApiFeatureUsage
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