MediaWiki  master
ISearchResultSet Interface Reference

A set of SearchEngine results. More...

Inheritance diagram for ISearchResultSet:
Collaboration diagram for ISearchResultSet:

Public Member Functions

 augmentResult (SearchResult $result)
 Returns extra data for specific result and store it in SearchResult object. More...
 
 extractResults ()
 Extract all the results in the result set as array. More...
 
 extractTitles ()
 Extract all the titles in the result set. More...
 
 getInterwikiResults ( $type=self::SECONDARY_RESULTS)
 Return a result set of hits on other (multiple) wikis associated with this one. More...
 
 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...
 
 numRows ()
 
 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)
 

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...
 

Detailed Description

A set of SearchEngine results.

Must not be directly implemented by extension, please extend BaseSearchResultSet instead. This interface must only be used for type hinting.

@unstable for implementation, extensions should extend the BaseSearchResultSet base class.

See also
BaseSearchResultSet

Definition at line 12 of file ISearchResultSet.php.

Member Function Documentation

◆ augmentResult()

ISearchResultSet::augmentResult ( SearchResult  $result)

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

Parameters
SearchResult$result

Referenced by SqlSearchResultSet\extractResults().

◆ extractResults()

ISearchResultSet::extractResults ( )

Extract all the results in the result set as array.

Returns
SearchResult[]

Implemented in SearchResultSet, and SqlSearchResultSet.

Referenced by PerRowAugmentor\augmentAll().

◆ extractTitles()

ISearchResultSet::extractTitles ( )

Extract all the titles in the result set.

Returns
Title[]

Implemented in SearchResultSet.

Referenced by AugmentPageProps\augmentAll().

◆ getInterwikiResults()

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

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

Parameters
int$type
Returns
ISearchResultSet[]

Implemented in SearchResultSet.

◆ getOffset()

ISearchResultSet::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.

◆ getQueryAfterRewrite()

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

Implemented in SearchResultSet.

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

◆ getQueryAfterRewriteSnippet()

ISearchResultSet::getQueryAfterRewriteSnippet ( )
Returns
HtmlArmor|string|null Same as self::getQueryAfterRewrite(), but with changes to the string highlighted in HTML and wrapped in HtmlArmor. If highlighting is not available the rewritten query will be returned. When the self::hasRewrittenQuery returns false (i.e. the results have not been rewritten) null will be returned.

Implemented in SearchResultSet.

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

◆ getSuggestionQuery()

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

Implemented in SearchResultSet.

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

◆ getSuggestionSnippet()

ISearchResultSet::getSuggestionSnippet ( )
Returns
HtmlArmor|string Same as self::getSuggestionQuery(), but with changes to the string highlighted in HTML and wrapped in HtmlArmor. If highlighting is not available the suggested query will be returned. When self::hasSuggestion returns false (i.e no suggested query) the empty string will be returned.

Implemented in SearchResultSet.

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

◆ getTotalHits()

ISearchResultSet::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|null

Implemented in SearchResultSet, SqlSearchResultSet, and FauxSearchResultSet.

◆ hasInterwikiResults()

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

Check if there are results on other wikis.

Parameters
int$type
Returns
bool

Implemented in SearchResultSet.

◆ hasMoreResults()

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

Implemented in SearchResultSet.

◆ hasRewrittenQuery()

ISearchResultSet::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.

NOTE: In practice this has only been applied when the original query returned no results. UI messages, such as search-rewritten, have this assumption baked in.

Returns
bool

Implemented in SearchResultSet.

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

◆ hasSuggestion()

ISearchResultSet::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

Implemented in SearchResultSet.

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

◆ numRows()

ISearchResultSet::numRows ( )

◆ searchContainedSyntax()

ISearchResultSet::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

Implemented in SearchResultSet.

◆ setAugmentedData()

ISearchResultSet::setAugmentedData (   $name,
  $data 
)

Sets augmented data for result set.

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

Referenced by SearchEngine\augmentSearchResults().

◆ shrink()

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

Implemented in SearchResultSet.

Member Data Documentation

◆ INLINE_RESULTS

const ISearchResultSet::INLINE_RESULTS = 1

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

Definition at line 23 of file ISearchResultSet.php.

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

◆ SECONDARY_RESULTS

const ISearchResultSet::SECONDARY_RESULTS = 0

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

Definition at line 17 of file ISearchResultSet.php.

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


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