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

Change subject: Deprecate Searcher::getAndFilterExtraIndexes
......................................................................

Deprecate Searcher::getAndFilterExtraIndexes

This method was doing 2 things and was annoying.

Change-Id: Iad962f177399f60881bf6f24403412642bee9ea7
---
M includes/InterwikiSearcher.php
M includes/Search/SearchContext.php
M includes/Searcher.php
3 files changed, 26 insertions(+), 25 deletions(-)


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

diff --git a/includes/InterwikiSearcher.php b/includes/InterwikiSearcher.php
index c1438df..66431f9 100644
--- a/includes/InterwikiSearcher.php
+++ b/includes/InterwikiSearcher.php
@@ -129,16 +129,6 @@
        }
 
        /**
-        * We don't support extra indices when we're doing interwiki searches
-        *
-        * @see Searcher::getAndFilterExtraIndexes()
-        * @return array
-        */
-       protected function getAndFilterExtraIndexes() {
-               return [];
-       }
-
-       /**
         * @return string The stats key used for reporting hit/miss rates of the
         *  application side query cache.
         */
diff --git a/includes/Search/SearchContext.php 
b/includes/Search/SearchContext.php
index f5188c1..2a25c1b 100644
--- a/includes/Search/SearchContext.php
+++ b/includes/Search/SearchContext.php
@@ -2,6 +2,7 @@
 
 namespace CirrusSearch\Search;
 
+use CirrusSearch\OtherIndexes;
 use CirrusSearch\SearchConfig;
 use Elastica\Query\AbstractQuery;
 
@@ -902,4 +903,20 @@
                return $this->resultsType;
        }
 
+       /**
+        * Get the list of extra indices to query.
+        * Generally needed to query externilized file index.
+        * Must be called only once the list of namespaces has been set.
+        *
+        * @return string[]
+        * @see OtherIndexes::getExtraIndexesForNamespaces()
+        */
+       public function getExtraIndices() {
+               if ( $this->getLimitSearchToLocalWiki() || 
!$this->getNamespaces() ) {
+                       return [];
+               }
+               return OtherIndexes::getExtraIndexesForNamespaces(
+                       $this->getNamespaces()
+               );
+       }
 }
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 112e742..29a29db 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -505,8 +505,13 @@
 
                $this->overrideConnectionIfNeeded();
                if ( $namespaces ) {
-                       $extraIndexes = $this->getAndFilterExtraIndexes();
                        $this->searchContext->addFilter( new 
\Elastica\Query\Terms( 'namespace', $namespaces ) );
+                       $extraIndexes = $this->searchContext->getExtraIndices();
+                       if ( !empty( $extraIndexes ) ) {
+                               $this->searchContext->addNotFilter( new 
\Elastica\Query\Term(
+                                       [ 'local_sites_with_dupe' => 
$this->indexBaseName ]
+                               ) );
+                       }
                        foreach ( $extraIndexes as $extraIndex ) {
                                $extraIndexBoosts = $this->config->getElement( 
'CirrusSearchExtraIndexBoostTemplates', $extraIndex );
                                if ( isset( $extraIndexBoosts['wiki'], 
$extraIndexBoosts['boosts'] ) ) {
@@ -851,22 +856,11 @@
         * Retrieve the extra indexes for our searchable namespaces, if any
         * exist. If they do exist, also add our wiki to our notFilters so
         * we can filter out duplicates properly.
-        *
-        * @return string[]
+        * @deprecated (NOOP: no longer called)
+        * @return string[] empty array
         */
        protected function getAndFilterExtraIndexes() {
-               if ( $this->searchContext->getLimitSearchToLocalWiki() ) {
-                       return [];
-               }
-               $extraIndexes = OtherIndexes::getExtraIndexesForNamespaces(
-                       $this->searchContext->getNamespaces()
-               );
-               if ( $extraIndexes ) {
-                       $this->searchContext->addNotFilter( new 
\Elastica\Query\Term(
-                               [ 'local_sites_with_dupe' => 
$this->indexBaseName ]
-                       ) );
-               }
-               return $extraIndexes;
+               return [];
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad962f177399f60881bf6f24403412642bee9ea7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <dcau...@wikimedia.org>

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

Reply via email to