MediaWiki
1.32.5
|
Search suggestion sets. More...
Public Member Functions | |
__construct (array $suggestions, $hasMoreResults=false) | |
Builds a new set of suggestions. More... | |
append (SearchSuggestion $suggestion) | |
Add a new suggestion at the end. More... | |
appendAll (SearchSuggestionSet $set) | |
Add suggestion set to the end of the current one. More... | |
filter ( $callback) | |
Filter the suggestions array. More... | |
getBestScore () | |
getSize () | |
getSuggestions () | |
Get the list of suggestions. More... | |
getWorstScore () | |
hasMoreResults () | |
map ( $callback) | |
Call array_map on the suggestions array. More... | |
prepend (SearchSuggestion $suggestion) | |
Add a new suggestion at the top. More... | |
rescore ( $key) | |
Move the suggestion at index $key to the first position. More... | |
shrink ( $limit) | |
Remove any extra elements in the suggestions set. More... | |
Static Public Member Functions | |
static | emptySuggestionSet () |
static | fromStrings (array $titles, $hasMoreResults=false) |
Builds a new set of suggestion based on a string array. More... | |
static | fromTitles (array $titles, $hasMoreResults=false) |
Builds a new set of suggestion based on a title array. More... | |
Private Attributes | |
bool | $hasMoreResults |
Are more results available? More... | |
array | $pageMap = [] |
SearchSuggestion[] | $suggestions = [] |
Search suggestion sets.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html A set of search suggestions. The set is always ordered by score, with the best match first.
Definition at line 26 of file SearchSuggestionSet.php.
Builds a new set of suggestions.
NOTE: the array should be sorted by score (higher is better), in descending order. SearchSuggestionSet will not try to re-order this input array. Providing an unsorted input array is a mistake and will lead to unexpected behaviors.
SearchSuggestion[] | $suggestions | (must be sorted by score) |
bool | $hasMoreResults | Are more results available? |
Definition at line 55 of file SearchSuggestionSet.php.
References $hasMoreResults, as, and hasMoreResults().
SearchSuggestionSet::append | ( | SearchSuggestion | $suggestion | ) |
Add a new suggestion at the end.
If the score of the new suggestion is greater than the worst one, the new suggestion score will be updated (worst - 1).
SearchSuggestion | $suggestion |
Definition at line 109 of file SearchSuggestionSet.php.
References SearchSuggestion\getScore(), getSize(), SearchSuggestion\getSuggestedTitleID(), getWorstScore(), and SearchSuggestion\setScore().
Referenced by appendAll().
SearchSuggestionSet::appendAll | ( | SearchSuggestionSet | $set | ) |
Add suggestion set to the end of the current one.
SearchSuggestionSet | $set |
Definition at line 127 of file SearchSuggestionSet.php.
References append(), as, and getSuggestions().
|
static |
Definition at line 238 of file SearchSuggestionSet.php.
Referenced by SearchEngine\completionSearch(), MockCompletionSearchEngine\completionSearchBackend(), SearchEngine\completionSearchWithVariants(), SearchSuggestionSetTest\testAppend(), SearchSuggestionSetTest\testInsertBest(), and SearchSuggestionSetTest\testShrink().
SearchSuggestionSet::filter | ( | $callback | ) |
Filter the suggestions array.
callback | $callback | Callable accepting single SearchSuggestion instance returning bool false to remove the item. |
Definition at line 96 of file SearchSuggestionSet.php.
References captcha-old\count.
Referenced by SearchEngine\processCompletionResults().
Builds a new set of suggestion based on a string array.
NOTE: Suggestion scores will be generated.
string[] | $titles | |
bool | $hasMoreResults | Are more results available? |
Definition at line 227 of file SearchSuggestionSet.php.
References $hasMoreResults, $suggestions, $title, $titles, captcha-old\count, SearchSuggestion\fromText(), and use.
Referenced by MockCompletionSearchEngine\completionSearchBackend(), SearchEngine\completionSearchBackend(), and SearchEnginePrefixTest\mockSearchWithResults().
Builds a new set of suggestion based on a title array.
Useful when using a backend that supports only Titles.
NOTE: Suggestion scores will be generated.
Title[] | $titles | |
bool | $hasMoreResults | Are more results available? |
Definition at line 210 of file SearchSuggestionSet.php.
References $hasMoreResults, $suggestions, $title, $titles, captcha-old\count, SearchSuggestion\fromTitle(), and use.
Referenced by SearchEngine\completionSearchBackend().
SearchSuggestionSet::getBestScore | ( | ) |
Definition at line 165 of file SearchSuggestionSet.php.
Referenced by prepend().
SearchSuggestionSet::getSize | ( | ) |
Definition at line 185 of file SearchSuggestionSet.php.
References captcha-old\count.
SearchSuggestionSet::getSuggestions | ( | ) |
Get the list of suggestions.
Definition at line 77 of file SearchSuggestionSet.php.
References $suggestions.
Referenced by appendAll().
SearchSuggestionSet::getWorstScore | ( | ) |
Definition at line 175 of file SearchSuggestionSet.php.
Referenced by append().
SearchSuggestionSet::hasMoreResults | ( | ) |
Definition at line 69 of file SearchSuggestionSet.php.
References $hasMoreResults.
Referenced by __construct(), and shrink().
SearchSuggestionSet::map | ( | $callback | ) |
Call array_map on the suggestions array.
callback | $callback |
Definition at line 86 of file SearchSuggestionSet.php.
Referenced by SearchEngine\extractTitles(), and SearchEngine\processCompletionResults().
SearchSuggestionSet::prepend | ( | SearchSuggestion | $suggestion | ) |
Add a new suggestion at the top.
If the new suggestion score is lower than the best one its score will be updated (best + 1)
SearchSuggestion | $suggestion |
Definition at line 148 of file SearchSuggestionSet.php.
References getBestScore(), SearchSuggestion\getScore(), getSize(), SearchSuggestion\getSuggestedTitleID(), and SearchSuggestion\setScore().
Referenced by SearchEngine\processCompletionResults(), and rescore().
SearchSuggestionSet::rescore | ( | $key | ) |
Move the suggestion at index $key to the first position.
string | $key |
Definition at line 137 of file SearchSuggestionSet.php.
References prepend().
Referenced by SearchEngine\processCompletionResults().
SearchSuggestionSet::shrink | ( | $limit | ) |
Remove any extra elements in the suggestions set.
int | $limit | the max size of this set. |
Definition at line 193 of file SearchSuggestionSet.php.
References captcha-old\count, and hasMoreResults().
Referenced by SearchEngine\processCompletionResults().
|
private |
Are more results available?
Definition at line 41 of file SearchSuggestionSet.php.
Referenced by __construct(), fromStrings(), fromTitles(), and hasMoreResults().
|
private |
Definition at line 36 of file SearchSuggestionSet.php.
|
private |
Definition at line 30 of file SearchSuggestionSet.php.
Referenced by fromStrings(), fromTitles(), and getSuggestions().