jenkins-bot has submitted this change and it was merged. ( 
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(-)

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



diff --git a/ApiFeatureUsageQueryEngineElastica.php 
b/ApiFeatureUsageQueryEngineElastica.php
index a2fabd0..db8f8c0 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: merged
Gerrit-Change-Id: I506862c1ed4729103f76417b85cdc9b0773cd3f2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ApiFeatureUsage
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to