EBernhardson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/335164 )
Change subject: Highlight interwiki search results ...................................................................... Highlight interwiki search results The AB test requires interwiki search results to be highlighted. While it saves some amount of processing, the extra code complexity of supporting both highlighted and non-highlighted interwiki doesn't seem worthwhile. As such change to using FullTextResultsType for all interwiki searches. Change-Id: I24b5329d8b213e59143e3a7cacd0a752082d4755 --- M autoload.php M includes/InterwikiSearcher.php M includes/Search/ResultsType.php 3 files changed, 15 insertions(+), 47 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/64/335164/1 diff --git a/autoload.php b/autoload.php index 73ecdd4..4680a03 100644 --- a/autoload.php +++ b/autoload.php @@ -156,7 +156,6 @@ 'CirrusSearch\\Search\\IdResultsType' => __DIR__ . '/includes/Search/ResultsType.php', 'CirrusSearch\\Search\\IncomingLinksFunctionScoreBuilder' => __DIR__ . '/includes/Search/RescoreBuilders.php', 'CirrusSearch\\Search\\IntegerIndexField' => __DIR__ . '/includes/Search/IntegerIndexField.php', - 'CirrusSearch\\Search\\InterwikiResultsType' => __DIR__ . '/includes/Search/ResultsType.php', 'CirrusSearch\\Search\\InvalidRescoreProfileException' => __DIR__ . '/includes/Search/RescoreBuilders.php', 'CirrusSearch\\Search\\KeywordIndexField' => __DIR__ . '/includes/Search/KeywordIndexField.php', 'CirrusSearch\\Search\\LangWeightFunctionScoreBuilder' => __DIR__ . '/includes/Search/RescoreBuilders.php', diff --git a/includes/InterwikiSearcher.php b/includes/InterwikiSearcher.php index 2e6593a..b2ecf36 100644 --- a/includes/InterwikiSearcher.php +++ b/includes/InterwikiSearcher.php @@ -2,7 +2,7 @@ namespace CirrusSearch; -use CirrusSearch\Search\InterwikiResultsType; +use CirrusSearch\Search\FullTextResultsType; use CirrusSearch\Search\ResultSet; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; @@ -34,6 +34,11 @@ const MAX_COMPLEXITY = 10; /** + * @var int Highlighting bitfield + */ + private $highlightingConfig; + + /** * Constructor * @param Connection $connection * @param SearchConfig $config @@ -41,7 +46,13 @@ * @param User|null $user * @param string $index Base name for index to search from, defaults to $wgCirrusSearchIndexBaseName */ - public function __construct( Connection $connection, SearchConfig $config, array $namespaces = null, User $user = null ) { + public function __construct( + Connection $connection, + SearchConfig $config, + array $namespaces = null, + User $user = null, + $highlightingConfig = FullTextResultsType::HIGHLIGHT_NONE + ) { // Only allow core namespaces. We can't be sure any others exist if ( $namespaces !== null ) { $namespaces = array_filter( $namespaces, function( $namespace ) { @@ -50,6 +61,7 @@ } $maxResults = $config->get( 'CirrusSearchNumCrossProjectSearchResults' ); parent::__construct( $connection, 0, $maxResults, $config, $namespaces, $user ); + $this->highlightingConfig = $highlightingConfig; } /** @@ -97,7 +109,7 @@ // TODO: remove when getWikiCode is removed. // In theory we should be able to reuse the same // Results type for all searches - $resultsTypes[$interwiki] = new InterwikiResultsType( $this->config->newInterwikiConfig( $index, false ) ); + $resultsTypes[$interwiki] = new FullTextResultsType( $this->config->newInterwikiConfig( $index, false ), $this->highlightingConfig ); $this->setResultsType( $resultsTypes[$interwiki] ); $this->indexBaseName = $index; $this->searchContext = clone $context; diff --git a/includes/Search/ResultsType.php b/includes/Search/ResultsType.php index e6a87e9..e1485c8 100644 --- a/includes/Search/ResultsType.php +++ b/includes/Search/ResultsType.php @@ -597,46 +597,3 @@ return []; } } - -/** - * This class does exactly the same as TitleResultsType - * but returns a ResultSet instead of an array of titles - */ -class InterwikiResultsType extends BaseResultsType { - /** - * @param SearchContext $context - * @param \Elastica\ResultSet $result - * @return ResultSet - */ - public function transformElasticsearchResult( SearchContext $context, \Elastica\ResultSet $result ) { - return new ResultSet( - $context->getSuggestPrefixes(), - $context->getSuggestSuffixes(), - $result, - $context->isSpecialKeywordUsed(), - $this->getConfig() - ); - } - - /** - * @param array $highlightSource - * @return null - */ - public function getHighlightingConfiguration( array $highlightSource ) { - return null; - } - - /** - * @return false - */ - public function getFields() { - return false; - } - - /** - * @return EmptyResultSet - */ - public function createEmptyResult() { - return new EmptyResultSet(); - } -} -- To view, visit https://gerrit.wikimedia.org/r/335164 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I24b5329d8b213e59143e3a7cacd0a752082d4755 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits