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