/** @var bool */
protected $showSuggestion = true;
private $sort = 'relevance';
/** @var array Feature values */
/** @var bool */
protected $showSuggestion = true;
private $sort = 'relevance';
/** @var array Feature values */
public static function getNearMatch( $searchterm ) {
$title = self::getNearMatchInternal( $searchterm );
public static function getNearMatch( $searchterm ) {
$title = self::getNearMatchInternal( $searchterm );
private static function getNearMatchInternal( $searchterm ) {
global $wgContLang, $wgEnableSearchContributorsByIP;
private static function getNearMatchInternal( $searchterm ) {
global $wgContLang, $wgEnableSearchContributorsByIP;
if ( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) {
return SearchEngine::getNearMatch( $matches[1] );
}
if ( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) {
return SearchEngine::getNearMatch( $matches[1] );
}
$prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
$index = $wgContLang->getNsIndex( $prefix );
if ( $index !== false ) {
$prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
$index = $wgContLang->getNsIndex( $prefix );
if ( $index !== false ) {
foreach ( SearchEngine::searchableNamespaces() as $ns => $name ) {
if ( $user->getOption( 'searchNs' . $ns ) ) {
$arr[] = $ns;
foreach ( SearchEngine::searchableNamespaces() as $ns => $name ) {
if ( $user->getOption( 'searchNs' . $ns ) ) {
$arr[] = $ns;
public static function userHighlightPrefs() {
$contextlines = 2; // Hardcode this. Old defaults sucked. :)
$contextchars = 75; // same as above.... :P
public static function userHighlightPrefs() {
$contextlines = 2; // Hardcode this. Old defaults sucked. :)
$contextchars = 75; // same as above.... :P
public static function getSearchTypes() {
global $wgSearchType, $wgSearchTypeAlternatives;
public static function getSearchTypes() {
global $wgSearchType, $wgSearchTypeAlternatives;
$search = $title->getText();
if ( $ns[0] == NS_MAIN ) {
$ns = $this->namespaces; // no explicit prefix, use default namespaces
$search = $title->getText();
if ( $ns[0] == NS_MAIN ) {
$ns = $this->namespaces; // no explicit prefix, use default namespaces
$search = trim( $search );
if ( !in_array( NS_SPECIAL, $this->namespaces ) && // We do not run hook on Special: search
!Hooks::run( 'PrefixSearchBackend',
$search = trim( $search );
if ( !in_array( NS_SPECIAL, $this->namespaces ) && // We do not run hook on Special: search
!Hooks::run( 'PrefixSearchBackend',
- array( $this->namespaces, $search, $this->limit, &$results, $this->offset )
+ [ $this->namespaces, $search, $this->limit, &$results, $this->offset ]
) ) {
// False means hook worked.
// FIXME: Yes, the API is weird. That's why it is going to be deprecated.
) ) {
// False means hook worked.
// FIXME: Yes, the API is weird. That's why it is going to be deprecated.
* @return SearchSuggestionSet
*/
protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
* @return SearchSuggestionSet
*/
protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
$search = trim( $search );
// preload the titles with LinkBatch
$titles = $suggestions->map( function( SearchSuggestion $sugg ) {
$search = trim( $search );
// preload the titles with LinkBatch
$titles = $suggestions->map( function( SearchSuggestion $sugg ) {
+ // NOTE: in some cases like cross-namespace redirects
+ // (frequently used as shortcuts e.g. WP:WP on huwiki) some
+ // backends like Cirrus will return no results. We should still
+ // try an exact title match to workaround this limitation
$rescorer = new SearchExactMatchRescorer();
$rescoredResults = $rescorer->rescore( $search, $this->namespaces, $results, $this->limit );
$rescorer = new SearchExactMatchRescorer();
$rescoredResults = $rescorer->rescore( $search, $this->namespaces, $results, $this->limit );