global $wgContLang;
$search = $this->getSearchEngine();
+ $search->setFeatureData( 'rewrite', $this->runSuggestion );
$search->setLimitOffset( $this->limit, $this->offset );
$search->setNamespaces( $this->namespaces );
$search->prefix = $this->mPrefix;
// did you mean... suggestions
$didYouMeanHtml = '';
if ( $showSuggestion && $textMatches && !$textStatus ) {
- if ( $this->shouldRunSuggestedQuery( $textMatches ) ) {
- $newMatches = $search->searchText( $textMatches->getSuggestionQuery() );
- if ( $newMatches instanceof SearchResultSet && $newMatches->numRows() > 0 ) {
- $didYouMeanHtml = $this->getDidYouMeanRewrittenHtml( $term, $textMatches );
- $textMatches = $newMatches;
- }
+ if ( $textMatches->hasRewrittenQuery() ) {
+ $didYouMeanHtml = $this->getDidYouMeanRewrittenHtml( $term, $textMatches );
} elseif ( $textMatches->hasSuggestion() ) {
$didYouMeanHtml = $this->getDidYouMeanHtml( $textMatches );
}
* @return bool
*/
protected function shouldRunSuggestedQuery( SearchResultSet $textMatches ) {
- global $wgSearchRunSuggestedQueryPercent;
-
if ( !$this->runSuggestion ||
!$textMatches->hasSuggestion() ||
$textMatches->numRows() > 0 ||
// Generate a random number between 0 and 1. If the
// number is less than the desired percentages run it.
$rand = rand( 0, getrandmax() ) / getrandmax();
- return $wgSearchRunSuggestedQueryPercent > $rand;
+ return $this->getConfig()->get( 'SearchRunSuggestedQueryPercent' ) > $rand;
}
/**
// Showing results for '$rewritten'
// Search instead for '$orig'
- $params = array( 'search' => $textMatches->getSuggestionQuery() );
+ $params = array( 'search' => $textMatches->getQueryAfterRewrite() );
if ( $this->fulltext != null ) {
$params['fulltext'] = $this->fulltext;
}
$rewritten = Linker::linkKnown(
$this->getPageTitle(),
- $textMatches->getSuggestionSnippet() ?: null,
+ $textMatches->getQueryAfterRewriteSnippet() ?: null,
array(),
$stParams
);
return Html::rawElement(
'div',
array( 'class' => 'searchdidyoumean' ),
- $this->msg( 'search-rewritten')->rawParams( $rewritten, $original )->escaped()
+ $this->msg( 'search-rewritten' )->rawParams( $rewritten, $original )->escaped()
);
}