EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/231615
Change subject: allow specifying index baseName to runSearch.php
......................................................................
allow specifying index baseName to runSearch.php
Change-Id: I1c1bd4a25c32a441d87f07c8ab4f80c76f78f7f4
---
M includes/CirrusSearch.php
M includes/Searcher.php
M maintenance/runSearch.php
3 files changed, 22 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/15/231615/1
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index 9002048..2bd58b9 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -40,6 +40,15 @@
private $lastSearchMetrics;
/**
+ * @var string
+ */
+ private $indexBaseName;
+
+ public function __construct( $baseName = null ) {
+ $this->indexBaseName = $baseName === null ? wfWikiId() :
$baseName;
+ }
+
+ /**
* Override supports to shut off updates to Cirrus via the SearchEngine
infrastructure. Page
* updates and additions are chained on the end of the links update
job. Deletes are noticed
* via the ArticleDeleteComplete hook.
@@ -75,7 +84,7 @@
$context = RequestContext::getMain();
$user = $context->getUser();
- $searcher = new Searcher( $this->offset, $this->limit,
$this->namespaces, $user );
+ $searcher = new Searcher( $this->offset, $this->limit,
$this->namespaces, $user, $this->indexBaseName );
// Ignore leading ~ because it is used to force displaying
search results but not to effect them
if ( substr( $term, 0, 1 ) === '~' ) {
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 6a3f3b6..553e368 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -814,7 +814,7 @@
$queryOptions[ 'timeout' ] = $wgCirrusSearchSearchShardTimeout[
'default' ];
Connection::setTimeout( $wgCirrusSearchSearchShardTimeout[
'default' ] );
- $index = Connection::getIndex( wfWikiId(),
Connection::TITLE_SUGGEST_TYPE );
+ $index = Connection::getIndex( $this->indexBaseName,
Connection::TITLE_SUGGEST_TYPE );
$description = "completion suggest query for {query}";
$logContext = array(
'query' => $text,
diff --git a/maintenance/runSearch.php b/maintenance/runSearch.php
index 4e5c357..dfe7629 100644
--- a/maintenance/runSearch.php
+++ b/maintenance/runSearch.php
@@ -35,10 +35,14 @@
class RunSearch extends Maintenance {
+ protected $indexBaseName;
+
public function __construct() {
parent::__construct();
- $this->addDescription( "Run one or more searches against the
cluster. " .
- "search queries are read from stdin." );
+ $this->addDescription( 'Run one or more searches against the
cluster. ' .
+ 'search queries are read from stdin.' );
+ $this->addOption( 'baseName', 'What basename to use for all
indexes, ' .
+ 'defaults to wiki id', false, true );
$this->addOption( 'type', 'What type of search to run, prefix,
suggest or full_text. ' .
'defaults to full_text.', false, true );
$this->addOption( 'options', 'A JSON object mapping from global
variable to ' .
@@ -57,6 +61,8 @@
// Don't skew the dashboards by logging these requests to
// the global request log.
$wgCirrusSearchLogElasticRequests = false;
+
+ $this->indexBaseName = $this->getOption( 'baseName', wfWikiId()
);
$this->applyGlobals();
$callback = array( $this, 'consume' );
@@ -118,7 +124,7 @@
$searchType = $this->getOption( 'type', 'full_text' );
switch ( $searchType ) {
case 'full_text':
- $engine = new CirrusSearch;
+ $engine = new CirrusSearch( $this->indexBaseName );
$result = $engine->searchText( $query );
if ( $result instanceof Status ) {
return $result;
@@ -127,11 +133,11 @@
}
case 'prefix':
- $searcher = new Searcher( 0, 10 );
+ $searcher = new Searcher( 0, 10, null, null,
$this->indexBaseName );
return $searcher->prefixSearch( $query );
case 'suggest':
- $searcher = new Searcher( 0, 10 );
+ $searcher = new Searcher( 0, 10, null, null,
$this->indexBaseName );
$result = $searcher->suggest( $query );
if ( $result instanceof Status ) {
return $result;
--
To view, visit https://gerrit.wikimedia.org/r/231615
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c1bd4a25c32a441d87f07c8ab4f80c76f78f7f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits