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