MediaWiki  1.30.0
SearchExactMatchRescorer Class Reference

An utility class to rescore search results by looking for an exact match in the db and add the page found to the first position. More...

Public Member Functions

 rescore ( $search, $namespaces, $srchres, $limit)
 Default search backend does proper prefix searching, but custom backends may sort based on other algorithms that may cause the exact title match to not be in the results or be lower down the list. More...
 

Private Member Functions

 getRedirectTarget ( $title)
 Get a redirect's destination from a title. More...
 
 pullFront ( $key, $array)
 Returns an array where the element of $array at index $key becomes the first element. More...
 
 redirectTargetsToRedirect ( $titles)
 

Detailed Description

An utility class to rescore search results by looking for an exact match in the db and add the page found to the first position.

NOTE: extracted from TitlePrefixSearch

Definition at line 31 of file SearchExactMatchRescorer.php.

Member Function Documentation

◆ getRedirectTarget()

SearchExactMatchRescorer::getRedirectTarget (   $title)
private

Get a redirect's destination from a title.

Parameters
Title$titleA title to redirect. It may not redirect or even exist
Returns
null|string If title exists and redirects, get the destination's prefixed name

Definition at line 136 of file SearchExactMatchRescorer.php.

References $title, and WikiPage\factory().

Referenced by redirectTargetsToRedirect(), and rescore().

◆ pullFront()

SearchExactMatchRescorer::pullFront (   $key,
  $array 
)
private

Returns an array where the element of $array at index $key becomes the first element.

Parameters
int$keykey to pull to the front
Returns
array $array with the item at $key pulled to the front

Definition at line 125 of file SearchExactMatchRescorer.php.

Referenced by rescore().

◆ redirectTargetsToRedirect()

SearchExactMatchRescorer::redirectTargetsToRedirect (   $titles)
private
Parameters
string[]$titlesas strings
Returns
array redirect target prefixedText to index of title in titles that is a redirect to it.

Definition at line 103 of file SearchExactMatchRescorer.php.

References $title, $titles, as, getRedirectTarget(), and Title\newFromText().

Referenced by rescore().

◆ rescore()

SearchExactMatchRescorer::rescore (   $search,
  $namespaces,
  $srchres,
  $limit 
)

Default search backend does proper prefix searching, but custom backends may sort based on other algorithms that may cause the exact title match to not be in the results or be lower down the list.

Parameters
string$searchthe query
int[]$namespacesthe namespaces
string[]$srchresresults
int$limitthe max number of results to return
Returns
string[] munged results

Definition at line 42 of file SearchExactMatchRescorer.php.

References $namespaces, $t, captcha-old\count, getRedirectTarget(), Title\newFromText(), NS_MAIN, pullFront(), and redirectTargetsToRedirect().


The documentation for this class was generated from the following file: