Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | use MediaWiki\Title\Title; |
4 | |
5 | /** |
6 | * A set of SearchEngine results. |
7 | * |
8 | * Must not be implemented directly by extensions, extend BaseSearchResultSet instead. |
9 | * |
10 | * @stable to type |
11 | * @see BaseSearchResultSet |
12 | * @ingroup Search |
13 | */ |
14 | interface ISearchResultSet extends \Countable, \IteratorAggregate { |
15 | /** |
16 | * Identifier for interwiki results that are displayed only together with existing main wiki |
17 | * results. |
18 | */ |
19 | public const SECONDARY_RESULTS = 0; |
20 | |
21 | /** |
22 | * Identifier for interwiki results that can be displayed even if no existing main wiki results |
23 | * exist. |
24 | */ |
25 | public const INLINE_RESULTS = 1; |
26 | |
27 | /** |
28 | * @return int |
29 | */ |
30 | public function numRows(); |
31 | |
32 | /** |
33 | * Some search modes return a total hit count for the query |
34 | * in the entire article database. This may include pages |
35 | * in namespaces that would not be matched on the given |
36 | * settings. |
37 | * |
38 | * Return null if no total hits number is supported. |
39 | * |
40 | * @return int|null |
41 | */ |
42 | public function getTotalHits(); |
43 | |
44 | /** |
45 | * Some search modes will run an alternative query that it thinks gives |
46 | * a better result than the provided search. Returns true if this has |
47 | * occurred. |
48 | * |
49 | * NOTE: In practice this has only been applied when the original query |
50 | * returned no results. UI messages, such as `search-rewritten`, have |
51 | * this assumption baked in. |
52 | * |
53 | * @return bool |
54 | */ |
55 | public function hasRewrittenQuery(); |
56 | |
57 | /** |
58 | * @return string|null The search the query was internally rewritten to, |
59 | * or null when the result of the original query was returned. |
60 | */ |
61 | public function getQueryAfterRewrite(); |
62 | |
63 | /** |
64 | * @return HtmlArmor|string|null Same as self::getQueryAfterRewrite(), but |
65 | * with changes to the string highlighted in HTML and wrapped in |
66 | * HtmlArmor. If highlighting is not available the rewritten query will |
67 | * be returned. When the self::hasRewrittenQuery returns false (i.e. the |
68 | * results have not been rewritten) null will be returned. |
69 | */ |
70 | public function getQueryAfterRewriteSnippet(); |
71 | |
72 | /** |
73 | * Some search modes return a suggested alternate term if there are |
74 | * no exact hits. Returns true if there is one on this set. |
75 | * |
76 | * @return bool |
77 | */ |
78 | public function hasSuggestion(); |
79 | |
80 | /** |
81 | * @return string|null Suggested query, null if none |
82 | */ |
83 | public function getSuggestionQuery(); |
84 | |
85 | /** |
86 | * @return HtmlArmor|string Same as self::getSuggestionQuery(), but with |
87 | * changes to the string highlighted in HTML and wrapped in HtmlArmor. If |
88 | * highlighting is not available the suggested query will be returned. When |
89 | * self::hasSuggestion returns false (i.e no suggested query) the empty |
90 | * string will be returned. |
91 | */ |
92 | public function getSuggestionSnippet(); |
93 | |
94 | /** |
95 | * Return a result set of hits on other (multiple) wikis associated with this one |
96 | * |
97 | * @param int $type |
98 | * @return ISearchResultSet[] |
99 | */ |
100 | public function getInterwikiResults( $type = self::SECONDARY_RESULTS ); |
101 | |
102 | /** |
103 | * Check if there are results on other wikis |
104 | * |
105 | * @param int $type |
106 | * @return bool |
107 | */ |
108 | public function hasInterwikiResults( $type = self::SECONDARY_RESULTS ); |
109 | |
110 | /** |
111 | * Did the search contain search syntax? If so, Special:Search won't offer |
112 | * the user a link to a create a page named by the search string because the |
113 | * name would contain the search syntax. |
114 | * @return bool |
115 | */ |
116 | public function searchContainedSyntax(); |
117 | |
118 | /** |
119 | * @return bool True when there are more pages of search results available. |
120 | */ |
121 | public function hasMoreResults(); |
122 | |
123 | /** |
124 | * @param int $limit Shrink result set to $limit and flag |
125 | * if more results are available. |
126 | */ |
127 | public function shrink( $limit ); |
128 | |
129 | /** |
130 | * Extract all the results in the result set as array. |
131 | * @return SearchResult[] |
132 | */ |
133 | public function extractResults(); |
134 | |
135 | /** |
136 | * Extract all the titles in the result set. |
137 | * @return Title[] |
138 | */ |
139 | public function extractTitles(); |
140 | |
141 | /** |
142 | * Sets augmented data for result set. |
143 | * @param string $name Extra data item name |
144 | * @param array[] $data Extra data as PAGEID => data |
145 | */ |
146 | public function setAugmentedData( $name, $data ); |
147 | |
148 | /** |
149 | * Returns extra data for specific result and store it in SearchResult object. |
150 | * @param SearchResult $result |
151 | */ |
152 | public function augmentResult( SearchResult $result ); |
153 | |
154 | /** |
155 | * @return int|null The offset the current page starts at. Typically |
156 | * this should be null to allow the UI to decide on its own, but in |
157 | * special cases like interleaved AB tests specifying explicitly is |
158 | * necessary. |
159 | */ |
160 | public function getOffset(); |
161 | } |