Chad has uploaded a new change for review. https://gerrit.wikimedia.org/r/107621
Change subject: Avoid loading revisions for every search result ...................................................................... Avoid loading revisions for every search result The core SearchResult implementations are insane. initFromTitle() loads revisions for every single search result. The only place Cirrus still relies on this is isMissingRevision(). Since we know we're reasonably up to date, let's assume revisions are never missing. Change-Id: I85ef144376f6ec078b34bfb36fb28888002e7522 --- M includes/Result.php 1 file changed, 14 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/21/107621/1 diff --git a/includes/Result.php b/includes/Result.php index 5dca44b..6e49180 100644 --- a/includes/Result.php +++ b/includes/Result.php @@ -51,7 +51,10 @@ global $wgCirrusSearchShowScore; $title = Title::makeTitle( $result->namespace, $result->title ); - $this->initFromTitle( $title ); + $this->mTitle = $title; + if ( $this->getTitle()->getNamespace() == NS_FILE ) { + $this->mImage = wfFindFile( $this->mTitle ); + } $data = $result->getData(); // TODO remove ternary once text.word_count is available everywhere $this->wordCount = isset( $data['text.word_count'] ) ? $data['text.word_count'] : $result->text_words; @@ -63,8 +66,8 @@ $highlights = $this->swapInPlainHighlighting( $highlights, 'heading' ); if ( isset( $highlights[ 'title' ] ) ) { $nstext = ''; - if ( $title->getNamespace() !== 0 ) { - $nstext = $title->getNsText() . ':'; + if ( $this->getTitle()->getNamespace() !== 0 ) { + $nstext = $this->getTitle()->getNsText() . ':'; } $this->titleSnippet = $nstext . self::escapeHighlightedText( $highlights[ 'title' ][ 0 ] ); } else { @@ -105,6 +108,14 @@ } /** + * Assume we're never missing. We always know about page updates + * @return bool + */ + public function isMissingRevision() { + return false; + } + + /** * Swap plain highlighting into the highlighting field if there isn't any normal highlighting. * TODO remove when Elasticsearch issue 3757 is fixed. * @var $highlights array of highlighting results -- To view, visit https://gerrit.wikimedia.org/r/107621 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I85ef144376f6ec078b34bfb36fb28888002e7522 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Chad <ch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits