MediaWiki  master
SearchResultSet Class Reference
Inheritance diagram for SearchResultSet:
Collaboration diagram for SearchResultSet:

Public Member Functions

 __construct ( $containedSyntax=false, $hasMoreResults=false)
 
 augmentResult (SearchResult $result)
 Returns extra data for specific result and store it in SearchResult object. More...
 
 count ()
 
 extractResults ()
 Extract all the results in the result set as array. More...
 
 extractTitles ()
 Extract all the titles in the result set. More...
 
 free ()
 Frees the result set, if applicable. More...
 
 getInterwikiResults ( $type=self::SECONDARY_RESULTS)
 Return a result set of hits on other (multiple) wikis associated with this one. More...
 
 getIterator ()
 
 getOffset ()
 
 getQueryAfterRewrite ()
 
 getQueryAfterRewriteSnippet ()
 
 getSuggestionQuery ()
 
 getSuggestionSnippet ()
 
 getTotalHits ()
 Some search modes return a total hit count for the query in the entire article database. More...
 
 hasInterwikiResults ( $type=self::SECONDARY_RESULTS)
 Check if there are results on other wikis. More...
 
 hasMoreResults ()
 
 hasRewrittenQuery ()
 Some search modes will run an alternative query that it thinks gives a better result than the provided search. More...
 
 hasSuggestion ()
 Some search modes return a suggested alternate term if there are no exact hits. More...
 
 next ()
 Fetches next search result, or false. More...
 
 numRows ()
 
 rewind ()
 Rewind result set back to beginning. More...
 
 searchContainedSyntax ()
 Did the search contain search syntax? If so, Special:Search won't offer the user a link to a create a page named by the search string because the name would contain the search syntax. More...
 
 setAugmentedData ( $name, $data)
 Sets augmented data for result set. More...
 
 shrink ( $limit)
 
 termMatches ()
 Fetch an array of regular expression fragments for matching the search terms as parsed by this engine in a text extract. More...
 

Public Attributes

const INLINE_RESULTS = 1
 Identifier for interwiki results that can be displayed even if no existing main wiki results exist. More...
 
const SECONDARY_RESULTS = 0
 Identifier for interwiki results that are displayed only together with existing main wiki results. More...
 

Protected Attributes

 $containedSyntax = false
 
array [] $extraData = []
 Set of result's extra data, indexed per result id and then per data item name. More...
 
SearchResult [] $results
 Cache of results - serialization of the result iterator as an array. More...
 

Private Member Functions

 bcIterator ()
 

Private Attributes

ArrayIterator null $bcIterator
 Iterator supporting BC iteration methods. More...
 
boolean $hasMoreResults
 True when there are more pages of search results available. More...
 
Title [] $titles
 Cache of titles. More...
 

Detailed Description

Definition at line 27 of file SearchResultSet.php.

Constructor & Destructor Documentation

◆ __construct()

SearchResultSet::__construct (   $containedSyntax = false,
  $hasMoreResults = false 
)
Parameters
bool$containedSyntaxTrue when query is not requesting a simple term match
bool$hasMoreResultsTrue when there are more pages of search results available.

Definition at line 82 of file SearchResultSet.php.

References $containedSyntax, $hasMoreResults, class, hasMoreResults(), and wfDeprecated().

Member Function Documentation

◆ augmentResult()

SearchResultSet::augmentResult ( SearchResult  $result)

Returns extra data for specific result and store it in SearchResult object.

Parameters
SearchResult$result

Definition at line 335 of file SearchResultSet.php.

References SearchResult\getTitle(), SearchResult\setExtensionData(), and use.

Referenced by SqlSearchResultSet\extractResults().

◆ bcIterator()

SearchResultSet::bcIterator ( )
private

Definition at line 220 of file SearchResultSet.php.

References $bcIterator, class, getIterator(), null, and wfDeprecated().

Referenced by next(), and rewind().

◆ count()

SearchResultSet::count ( )
final

◆ extractResults()

SearchResultSet::extractResults ( )

Extract all the results in the result set as array.

Returns
SearchResult[]

Definition at line 284 of file SearchResultSet.php.

References $results, next(), numRows(), and rewind().

Referenced by PerRowAugmentor\augmentAll(), count(), extractTitles(), and getIterator().

◆ extractTitles()

SearchResultSet::extractTitles ( )

Extract all the titles in the result set.

Returns
Title[]

Definition at line 304 of file SearchResultSet.php.

References $titles, extractResults(), SearchResult\getTitle(), and numRows().

Referenced by AugmentPageProps\augmentAll().

◆ free()

SearchResultSet::free ( )

Frees the result set, if applicable.

Definition at line 238 of file SearchResultSet.php.

◆ getInterwikiResults()

SearchResultSet::getInterwikiResults (   $type = self::SECONDARY_RESULTS)

Return a result set of hits on other (multiple) wikis associated with this one.

Parameters
int$type
Returns
SearchResultSet[]

Definition at line 184 of file SearchResultSet.php.

References null.

Referenced by ApiQuerySearch\addInterwikiResults().

◆ getIterator()

SearchResultSet::getIterator ( )
final

Definition at line 355 of file SearchResultSet.php.

References extractResults().

Referenced by bcIterator().

◆ getOffset()

SearchResultSet::getOffset ( )
Returns
int|null The offset the current page starts at. Typically this should be null to allow the UI to decide on its own, but in special cases like interleaved AB tests specifying explicitly is necessary.

Definition at line 351 of file SearchResultSet.php.

References null.

◆ getQueryAfterRewrite()

SearchResultSet::getQueryAfterRewrite ( )
Returns
string|null The search the query was internally rewritten to, or null when the result of the original query was returned.

Definition at line 142 of file SearchResultSet.php.

References null.

Referenced by MediaWiki\Widget\Search\DidYouMeanWidget\rewrittenHtml().

◆ getQueryAfterRewriteSnippet()

SearchResultSet::getQueryAfterRewriteSnippet ( )
Returns
string|null Same as self::getQueryAfterRewrite(), but in HTML and with changes highlighted. Null when the query was not rewritten.

Definition at line 150 of file SearchResultSet.php.

References null.

Referenced by MediaWiki\Widget\Search\DidYouMeanWidget\rewrittenHtml().

◆ getSuggestionQuery()

SearchResultSet::getSuggestionQuery ( )
Returns
string|null Suggested query, null if none

Definition at line 167 of file SearchResultSet.php.

References null.

Referenced by MediaWiki\Widget\Search\DidYouMeanWidget\suggestionHtml().

◆ getSuggestionSnippet()

SearchResultSet::getSuggestionSnippet ( )
Returns
string HTML highlighted suggested query, '' if none

Definition at line 174 of file SearchResultSet.php.

Referenced by MediaWiki\Widget\Search\DidYouMeanWidget\suggestionHtml().

◆ getTotalHits()

SearchResultSet::getTotalHits ( )

Some search modes return a total hit count for the query in the entire article database.

This may include pages in namespaces that would not be matched on the given settings.

Return null if no total hits number is supported.

Returns
int

Definition at line 123 of file SearchResultSet.php.

References null.

◆ hasInterwikiResults()

SearchResultSet::hasInterwikiResults (   $type = self::SECONDARY_RESULTS)

Check if there are results on other wikis.

Parameters
int$type
Returns
bool

Definition at line 194 of file SearchResultSet.php.

Referenced by ApiQuerySearch\addInterwikiResults().

◆ hasMoreResults()

SearchResultSet::hasMoreResults ( )
Returns
bool True when there are more pages of search results available.

Definition at line 255 of file SearchResultSet.php.

References $hasMoreResults.

Referenced by __construct(), and shrink().

◆ hasRewrittenQuery()

SearchResultSet::hasRewrittenQuery ( )

Some search modes will run an alternative query that it thinks gives a better result than the provided search.

Returns true if this has occurred.

Returns
bool

Definition at line 134 of file SearchResultSet.php.

Referenced by MediaWiki\Widget\Search\DidYouMeanWidget\render().

◆ hasSuggestion()

SearchResultSet::hasSuggestion ( )

Some search modes return a suggested alternate term if there are no exact hits.

Returns true if there is one on this set.

Returns
bool

Definition at line 160 of file SearchResultSet.php.

Referenced by MediaWiki\Widget\Search\DidYouMeanWidget\render().

◆ next()

SearchResultSet::next ( )

Fetches next search result, or false.

Deprecated:
since 1.32; Use self::extractResults() or foreach
Returns
SearchResult|false

Definition at line 203 of file SearchResultSet.php.

References bcIterator(), and wfDeprecated().

Referenced by extractResults().

◆ numRows()

SearchResultSet::numRows ( )

Definition at line 105 of file SearchResultSet.php.

References count().

Referenced by extractResults(), and extractTitles().

◆ rewind()

SearchResultSet::rewind ( )

Rewind result set back to beginning.

Deprecated:
since 1.32; Use self::extractResults() or foreach

Definition at line 215 of file SearchResultSet.php.

References bcIterator(), and wfDeprecated().

Referenced by extractResults().

◆ searchContainedSyntax()

SearchResultSet::searchContainedSyntax ( )

Did the search contain search syntax? If so, Special:Search won't offer the user a link to a create a page named by the search string because the name would contain the search syntax.

Returns
bool

Definition at line 248 of file SearchResultSet.php.

References $containedSyntax.

◆ setAugmentedData()

SearchResultSet::setAugmentedData (   $name,
  $data 
)

Sets augmented data for result set.

Parameters
string$nameExtra data item name
array[]$data Extra data as PAGEID => data

Definition at line 325 of file SearchResultSet.php.

References $name, and as.

Referenced by SearchEngine\augmentSearchResults().

◆ shrink()

SearchResultSet::shrink (   $limit)
Parameters
int$limitShrink result set to $limit and flag if more results are available.

Definition at line 263 of file SearchResultSet.php.

References count(), and hasMoreResults().

◆ termMatches()

SearchResultSet::termMatches ( )

Fetch an array of regular expression fragments for matching the search terms as parsed by this engine in a text extract.

STUB

Returns
string[]
Deprecated:
since 1.34 (use SqlSearchResult)

Definition at line 101 of file SearchResultSet.php.

Member Data Documentation

◆ $bcIterator

ArrayIterator null SearchResultSet::$bcIterator
private

Iterator supporting BC iteration methods.

Definition at line 74 of file SearchResultSet.php.

Referenced by bcIterator().

◆ $containedSyntax

SearchResultSet::$containedSyntax = false
protected

Definition at line 41 of file SearchResultSet.php.

Referenced by __construct(), and searchContainedSyntax().

◆ $extraData

array [] SearchResultSet::$extraData = []
protected

Set of result's extra data, indexed per result id and then per data item name.

The structure is: PAGE_ID => [ augmentor name => data, ... ]

Definition at line 64 of file SearchResultSet.php.

◆ $hasMoreResults

boolean SearchResultSet::$hasMoreResults
private

True when there are more pages of search results available.

Definition at line 69 of file SearchResultSet.php.

Referenced by __construct(), and hasMoreResults().

◆ $results

SearchResult [] SearchResultSet::$results
protected

Cache of results - serialization of the result iterator as an array.

Definition at line 55 of file SearchResultSet.php.

Referenced by MockSearchResultSet\__construct(), MockSearchResultSet\extractResults(), SqlSearchResultSet\extractResults(), and extractResults().

◆ $titles

Title [] SearchResultSet::$titles
private

Cache of titles.

Lists titles of the result set, in the same order as results.

Definition at line 48 of file SearchResultSet.php.

Referenced by extractTitles().

◆ INLINE_RESULTS

const SearchResultSet::INLINE_RESULTS = 1

Identifier for interwiki results that can be displayed even if no existing main wiki results exist.

Definition at line 39 of file SearchResultSet.php.

Referenced by MediaWiki\Widget\Search\BasicSearchResultSetWidget\render(), ApiQuerySearch\run(), and SpecialSearch\showResults().

◆ SECONDARY_RESULTS

const SearchResultSet::SECONDARY_RESULTS = 0

Identifier for interwiki results that are displayed only together with existing main wiki results.

Definition at line 33 of file SearchResultSet.php.

Referenced by ApiQuerySearchTest\provideInterwikiResults(), MediaWiki\Widget\Search\BasicSearchResultSetWidget\render(), ApiQuerySearch\run(), and SpecialSearch\showResults().


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