DCausse has uploaded a new change for review.
https://gerrit.wikimedia.org/r/315258
Change subject: Add completion support to ClusterOverride
......................................................................
Add completion support to ClusterOverride
It can be useful when we want to switch everything except completion
queries.
Change-Id: Ib32d0478309b6b482c6c5cf497e721545247e7e7
---
M CirrusSearch.php
M includes/CirrusSearch.php
M includes/Searcher.php
3 files changed, 14 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/58/315258/1
diff --git a/CirrusSearch.php b/CirrusSearch.php
index 122f79c..c7fa0ec 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -526,15 +526,16 @@
// be retrieved by elasticsearch.
$wgCirrusSearchMoreLikeThisUseFields = false;
-// This allows redirecting full text queries to a separate cluster configured
+// This allows redirecting queries to a separate cluster configured
// in $wgCirrusSearchClusters. Note that queries can use multiple features, in
// the case multiple features have overrides the first match wins.
//
-// Example sending more_like queries to codfw:
-// $wgCirrusSearchFullTextClusterOverrides = array(
+// Example sending more_like queries to codfw and completion to eqiad:
+// $wgCirrusSearchClusterOverrides = [
// 'more_like' => 'codfw',
-// );
-$wgCirrusSearchFullTextClusterOverrides = array();
+// 'completion' => 'eqiad',
+// ];
+$wgCirrusSearchClusterOverrides = [];
// More like this queries can be quite expensive. Set this to > 0 to cache the
// results for the specified # of seconds into ObjectCache (memcache, redis, or
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index ce43cd0..04c6ad0 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -491,9 +491,13 @@
if ( isset(
$this->features[SearchEngine::COMPLETION_PROFILE_TYPE] ) ) {
$profile =
$this->features[SearchEngine::COMPLETION_PROFILE_TYPE];
}
- // offset is omitted, searchSuggestion does not support
- // scrolling results
- $suggester = new CompletionSuggester( $this->connection,
$this->limit,
+ $clusterOverride = $config->getElement(
'CirrusSearchClusterOverrides', 'completion' );
+ if ( $clusterOverride !== null ) {
+ $connection = Connection::getPool( $config,
$clusterOverride );
+ } else {
+ $connection = $this->connection;
+ }
+ $suggester = new CompletionSuggester( $connection, $this->limit,
$this->offset, $config, $this->namespaces, null,
$this->indexBaseName, $profile );
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 48c3414..2c7034e 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -837,7 +837,7 @@
* features to specific clusters.
*/
private function overrideConnectionIfNeeded() {
- $overrides = $this->config->get(
'CirrusSearchFullTextClusterOverrides' );
+ $overrides = $this->config->get( 'CirrusSearchClusterOverrides'
);
foreach ( $overrides as $feature => $cluster ) {
if ( $this->searchContext->isSyntaxUsed( $feature ) ) {
$this->connection = Connection::getPool(
$this->config, $cluster );
--
To view, visit https://gerrit.wikimedia.org/r/315258
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib32d0478309b6b482c6c5cf497e721545247e7e7
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