jenkins-bot has submitted this change and it was merged. Change subject: Use proper index type ......................................................................
Use proper index type Bug: T137177 Change-Id: I54cb3a3eda887d877f18c8ab8f617ba8338c321c --- M includes/Searcher.php M includes/api/ApiQueryGeoSearchElastic.php 2 files changed, 8 insertions(+), 6 deletions(-) Approvals: EBernhardson: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Searcher.php b/includes/Searcher.php index ce6d3bc..03c6cbb 100644 --- a/includes/Searcher.php +++ b/includes/Searcher.php @@ -25,12 +25,14 @@ * Perform search * * @param \Elastica\Query $query + * @param int[] $namespaces Namespaces used * @param string $queryType Query description for logging * @return \Elastica\ResultSet * @throws ExceptionInterface */ - public function performSearch( \Elastica\Query $query, $queryType ) { - $pageType = $this->connection->getPageType( wfWikiID() ); + public function performSearch( \Elastica\Query $query, array $namespaces, $queryType ) { + $indexType = $this->connection->pickIndexTypeForNamespaces( $namespaces ); + $pageType = $this->connection->getPageType( wfWikiID(), $indexType ); $search = $pageType->createSearch( $query ); try { diff --git a/includes/api/ApiQueryGeoSearchElastic.php b/includes/api/ApiQueryGeoSearchElastic.php index 29fccda..d6df0b4 100644 --- a/includes/api/ApiQueryGeoSearchElastic.php +++ b/includes/api/ApiQueryGeoSearchElastic.php @@ -24,6 +24,7 @@ $this->resetQueryParams(); //@fixme: refactor to make this unnecessary $params = $this->params = $this->extractRequestParams(); + $namespaces = array_map( 'intval', $params['namespace'] ); $filter = new \Elastica\Query\BoolQuery(); @@ -68,11 +69,10 @@ $nested = new \Elastica\Query\Nested(); $nested->setPath( 'coordinates' )->setQuery( $filter ); - if ( count( $params['namespace'] ) < count( MWNamespace::getValidNamespaces() ) ) { + if ( count( $namespaces ) < count( MWNamespace::getValidNamespaces() ) ) { $outerFilter = new \Elastica\Query\BoolQuery(); $outerFilter->addFilter( $nested ); - $outerFilter->addFilter( new \Elastica\Query\Terms( 'namespace', - $params['namespace'] ) ); + $outerFilter->addFilter( new \Elastica\Query\Terms( 'namespace', $namespaces ) ); $query->setPostFilter( $outerFilter ); } else { $query->setPostFilter( $nested ); @@ -93,7 +93,7 @@ $searcher = new Searcher( $this->getUser() ); - $resultSet = $searcher->performSearch( $query, 'GeoData_spatial_search' ); + $resultSet = $searcher->performSearch( $query, $namespaces, 'GeoData_spatial_search' ); if ( isset( $params['debug'] ) && $params['debug'] ) { $this->addDebugInfo( $resultSet, $query ); -- To view, visit https://gerrit.wikimedia.org/r/293216 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I54cb3a3eda887d877f18c8ab8f617ba8338c321c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GeoData Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits