Manybubbles has uploaded a new change for review. https://gerrit.wikimedia.org/r/117311
Change subject: If namespace doesn't have a weight default to .2 ...................................................................... If namespace doesn't have a weight default to .2 Bug: 62056 Change-Id: I8d1c7aa09759be57bcc4f9a8221a8c28db417143 --- M CirrusSearch.php M includes/Searcher.php 2 files changed, 21 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/11/117311/1 diff --git a/CirrusSearch.php b/CirrusSearch.php index 958095e..7d23a41 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -185,20 +185,24 @@ // matches. $wgCirrusSearchStemmedWeight = 0.5; -// Weight of each namespace relative. If not specified non-talk namespaces default to 0. If not -// specified talk namspaces default to: +// Weight of each namespace relative to NS_MAIN. If not specified non-talk namespaces default to +// $wgCirrusSearchDefaultNamespaceWeight. If not specified talk namspaces default to: // $wgCirrusSearchTalkNamespaceWeight * weightOfCorrespondingNonTalkNamespace -// The default values are inspired by the configuration used for lsearchd. +// The default values below inspired by the configuration used for lsearchd. Note that _technically_ +// NS_MAIN can be overriden with this then 1 just represents what NS_MAIN would have been.... +// If you override NS_MAIN here then NS_TALK will still default to: +// $wgCirrusSearchNamespaceWeights[ NS_MAIN ] * wgCirrusSearchTalkNamespaceWeight $wgCirrusSearchNamespaceWeights = array( NS_USER => 0.05, NS_PROJECT => 0.1, - NS_FILE => 0.2, NS_MEDIAWIKI => 0.05, NS_TEMPLATE => 0.005, NS_HELP => 0.1, - NS_CATEGORY => 0.2, ); +// Default weight of non-talks namespaces +$wgCirrusSearchDefaultNamespaceWeight = 0.2; + // Default weight of a talk namespace relative to its corresponding non-talk namespace. $wgCirrusSearchTalkNamespaceWeight = 0.25; diff --git a/includes/Searcher.php b/includes/Searcher.php index 30e0a9c..51bd94a 100644 --- a/includes/Searcher.php +++ b/includes/Searcher.php @@ -1268,25 +1268,32 @@ } /** - * Get the weight of a namespace. Public so it can be used in a callback. + * Get the weight of a namespace. * @param int $ns the namespace * @return float the weight of the namespace */ private function getBoostForNamespace( $ns ) { - global $wgCirrusSearchNamespaceWeights; - global $wgCirrusSearchTalkNamespaceWeight; + global $wgCirrusSearchNamespaceWeights, + $wgCirrusSearchDefaultNamespaceWeight, + $wgCirrusSearchTalkNamespaceWeight; if ( isset( $wgCirrusSearchNamespaceWeights[ $ns ] ) ) { return $wgCirrusSearchNamespaceWeights[ $ns ]; } if ( MWNamespace::isSubject( $ns ) ) { - return 1; + if ( $ns === NS_MAIN ) { + return 1; + } + return $wgCirrusSearchDefaultNamespaceWeight; } $subjectNs = MWNamespace::getSubject( $ns ); if ( isset( $wgCirrusSearchNamespaceWeights[ $subjectNs ] ) ) { return $wgCirrusSearchTalkNamespaceWeight * $wgCirrusSearchNamespaceWeights[ $subjectNs ]; } - return $wgCirrusSearchTalkNamespaceWeight; + if ( $ns === NS_TALK ) { + return $wgCirrusSearchTalkNamespaceWeight; + } + return $wgCirrusSearchDefaultNamespaceWeight * $wgCirrusSearchTalkNamespaceWeight; } private function checkTitleSearchRequestLength( $search ) { -- To view, visit https://gerrit.wikimedia.org/r/117311 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8d1c7aa09759be57bcc4f9a8221a8c28db417143 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Manybubbles <never...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits