MediaWiki  master
SearchEngine.php
Go to the documentation of this file.
1 <?php
31 
36 abstract class SearchEngine {
37  public const DEFAULT_SORT = 'relevance';
38 
40  public $prefix = '';
41 
43  public $namespaces = [ NS_MAIN ];
44 
46  protected $limit = 10;
47 
49  protected $offset = 0;
50 
55  protected $searchTerms = [];
56 
58  protected $showSuggestion = true;
60 
62  protected $features = [];
63 
65  private $hookContainer;
66 
68  private $hookRunner;
69 
71  public const COMPLETION_PROFILE_TYPE = 'completionSearchProfile';
72 
74  public const FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile';
75 
77  protected const CHARS_ALL = 1;
78 
80  protected const CHARS_NO_SYNTAX = 2;
81 
92  public function searchText( $term ) {
93  return $this->maybePaginate( function () use ( $term ) {
94  return $this->doSearchText( $term );
95  } );
96  }
97 
105  protected function doSearchText( $term ) {
106  return null;
107  }
108 
123  public function searchArchiveTitle( $term ) {
124  return $this->doSearchArchiveTitle( $term );
125  }
126 
134  protected function doSearchArchiveTitle( $term ) {
135  return Status::newGood( [] );
136  }
137 
149  public function searchTitle( $term ) {
150  return $this->maybePaginate( function () use ( $term ) {
151  return $this->doSearchTitle( $term );
152  } );
153  }
154 
162  protected function doSearchTitle( $term ) {
163  return null;
164  }
165 
174  private function maybePaginate( Closure $fn ) {
175  if ( $this instanceof PaginatingSearchEngine ) {
176  return $fn();
177  }
178  $this->limit++;
179  try {
180  $resultSetOrStatus = $fn();
181  } finally {
182  $this->limit--;
183  }
184 
185  $resultSet = null;
186  if ( $resultSetOrStatus instanceof ISearchResultSet ) {
187  $resultSet = $resultSetOrStatus;
188  } elseif ( $resultSetOrStatus instanceof Status &&
189  $resultSetOrStatus->getValue() instanceof ISearchResultSet
190  ) {
191  $resultSet = $resultSetOrStatus->getValue();
192  }
193  if ( $resultSet ) {
194  $resultSet->shrink( $this->limit );
195  }
196 
197  return $resultSetOrStatus;
198  }
199 
205  public function supports( $feature ) {
206  switch ( $feature ) {
207  case 'search-update':
208  return true;
209  case 'title-suffix-filter':
210  default:
211  return false;
212  }
213  }
214 
221  public function setFeatureData( $feature, $data ) {
222  $this->features[$feature] = $data;
223  }
224 
232  public function getFeatureData( $feature ) {
233  return $this->features[$feature] ?? null;
234  }
235 
244  public function normalizeText( $string ) {
245  // Some languages such as Chinese require word segmentation
246  return MediaWikiServices::getInstance()->getContentLanguage()->segmentByWord( $string );
247  }
248 
254  public function getNearMatcher( Config $config ) {
255  return new SearchNearMatcher( $config,
256  MediaWikiServices::getInstance()->getContentLanguage(),
257  $this->getHookContainer()
258  );
259  }
260 
265  protected static function defaultNearMatcher() {
266  $services = MediaWikiServices::getInstance();
267  $config = $services->getMainConfig();
268  return $services->newSearchEngine()->getNearMatcher( $config );
269  }
270 
277  public function legalSearchChars( $type = self::CHARS_ALL ) {
278  return "A-Za-z_'.0-9\\x80-\\xFF\\-";
279  }
280 
288  public function setLimitOffset( $limit, $offset = 0 ) {
289  $this->limit = intval( $limit );
290  $this->offset = intval( $offset );
291  }
292 
299  public function setNamespaces( $namespaces ) {
300  if ( $namespaces ) {
301  // Filter namespaces to only keep valid ones
302  $validNs = MediaWikiServices::getInstance()->getSearchEngineConfig()->searchableNamespaces();
303  $namespaces = array_filter( $namespaces, function ( $ns ) use( $validNs ) {
304  return $ns < 0 || isset( $validNs[$ns] );
305  } );
306  } else {
307  $namespaces = [];
308  }
309  $this->namespaces = $namespaces;
310  }
311 
319  public function setShowSuggestion( $showSuggestion ) {
320  $this->showSuggestion = $showSuggestion;
321  }
322 
330  public function getValidSorts() {
331  return [ self::DEFAULT_SORT ];
332  }
333 
342  public function setSort( $sort ) {
343  if ( !in_array( $sort, $this->getValidSorts() ) ) {
344  throw new InvalidArgumentException( "Invalid sort: $sort. " .
345  "Must be one of: " . implode( ', ', $this->getValidSorts() ) );
346  }
347  $this->sort = $sort;
348  }
349 
356  public function getSort() {
357  return $this->sort;
358  }
359 
369  public function replacePrefixes( $query ) {
370  return $query;
371  }
372 
388  public static function parseNamespacePrefixes(
389  $query,
390  $withAllKeyword = true,
391  $withPrefixSearchExtractNamespaceHook = false
392  ) {
393  $parsed = $query;
394  if ( strpos( $query, ':' ) === false ) { // nothing to do
395  return false;
396  }
397  $extractedNamespace = null;
398 
399  $allQuery = false;
400  if ( $withAllKeyword ) {
401  $allkeywords = [];
402 
403  $allkeywords[] = wfMessage( 'searchall' )->inContentLanguage()->text() . ":";
404  // force all: so that we have a common syntax for all the wikis
405  if ( !in_array( 'all:', $allkeywords ) ) {
406  $allkeywords[] = 'all:';
407  }
408 
409  foreach ( $allkeywords as $kw ) {
410  if ( strncmp( $query, $kw, strlen( $kw ) ) == 0 ) {
411  $extractedNamespace = null;
412  $parsed = substr( $query, strlen( $kw ) );
413  $allQuery = true;
414  break;
415  }
416  }
417  }
418 
419  if ( !$allQuery && strpos( $query, ':' ) !== false ) {
420  $prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
421  $index = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $prefix );
422  if ( $index !== false ) {
423  $extractedNamespace = [ $index ];
424  $parsed = substr( $query, strlen( $prefix ) + 1 );
425  } elseif ( $withPrefixSearchExtractNamespaceHook ) {
426  $hookNamespaces = [ NS_MAIN ];
427  $hookQuery = $query;
428  Hooks::runner()->onPrefixSearchExtractNamespace( $hookNamespaces, $hookQuery );
429  if ( $hookQuery !== $query ) {
430  $parsed = $hookQuery;
431  $extractedNamespace = $hookNamespaces;
432  } else {
433  return false;
434  }
435  } else {
436  return false;
437  }
438  }
439 
440  return [ $parsed, $extractedNamespace ];
441  }
442 
450  public static function userHighlightPrefs() {
453  return [ $contextlines, $contextchars ];
454  }
455 
465  public function update( $id, $title, $text ) {
466  // no-op
467  }
468 
477  public function updateTitle( $id, $title ) {
478  // no-op
479  }
480 
489  public function delete( $id, $title ) {
490  // no-op
491  }
492 
504  public function getTextFromContent( Title $t, Content $c = null ) {
505  return $c ? $c->getTextForSearchIndex() : '';
506  }
507 
516  public function textAlreadyUpdatedForIndex() {
517  return false;
518  }
519 
526  protected function normalizeNamespaces( $search ) {
527  $queryAndNs = self::parseNamespacePrefixes( $search, false, true );
528  if ( $queryAndNs !== false ) {
529  $this->setNamespaces( $queryAndNs[1] );
530  return $queryAndNs[0];
531  }
532  return $search;
533  }
534 
542  protected function completionSearchBackendOverfetch( $search ) {
543  $this->limit++;
544  try {
545  return $this->completionSearchBackend( $search );
546  } finally {
547  $this->limit--;
548  }
549  }
550 
558  protected function completionSearchBackend( $search ) {
559  $results = [];
560 
561  $search = trim( $search );
562 
563  if ( !in_array( NS_SPECIAL, $this->namespaces ) && // We do not run hook on Special: search
564  !$this->getHookRunner()->onPrefixSearchBackend(
565  $this->namespaces, $search, $this->limit, $results, $this->offset )
566  ) {
567  // False means hook worked.
568  // FIXME: Yes, the API is weird. That's why it is going to be deprecated.
569 
570  return SearchSuggestionSet::fromStrings( $results );
571  } else {
572  // Hook did not do the job, use default simple search
573  $results = $this->simplePrefixSearch( $search );
574  return SearchSuggestionSet::fromTitles( $results );
575  }
576  }
577 
583  public function completionSearch( $search ) {
584  if ( trim( $search ) === '' ) {
585  return SearchSuggestionSet::emptySuggestionSet(); // Return empty result
586  }
587  $search = $this->normalizeNamespaces( $search );
588  $suggestions = $this->completionSearchBackendOverfetch( $search );
589  return $this->processCompletionResults( $search, $suggestions );
590  }
591 
597  public function completionSearchWithVariants( $search ) {
598  if ( trim( $search ) === '' ) {
599  return SearchSuggestionSet::emptySuggestionSet(); // Return empty result
600  }
601  $search = $this->normalizeNamespaces( $search );
602 
603  $results = $this->completionSearchBackendOverfetch( $search );
604  $fallbackLimit = 1 + $this->limit - $results->getSize();
605  if ( $fallbackLimit > 0 ) {
606  $fallbackSearches = MediaWikiServices::getInstance()->getContentLanguage()->
607  autoConvertToAllVariants( $search );
608  $fallbackSearches = array_diff( array_unique( $fallbackSearches ), [ $search ] );
609 
610  foreach ( $fallbackSearches as $fbs ) {
611  $this->setLimitOffset( $fallbackLimit );
612  $fallbackSearchResult = $this->completionSearch( $fbs );
613  $results->appendAll( $fallbackSearchResult );
614  $fallbackLimit -= $fallbackSearchResult->getSize();
615  if ( $fallbackLimit <= 0 ) {
616  break;
617  }
618  }
619  }
620  return $this->processCompletionResults( $search, $results );
621  }
622 
628  public function extractTitles( SearchSuggestionSet $completionResults ) {
629  return $completionResults->map( function ( SearchSuggestion $sugg ) {
630  return $sugg->getSuggestedTitle();
631  } );
632  }
633 
641  protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
642  // We over-fetched to determine pagination. Shrink back down if we have extra results
643  // and mark if pagination is possible
644  $suggestions->shrink( $this->limit );
645 
646  $search = trim( $search );
647  // preload the titles with LinkBatch
648  $lb = new LinkBatch( $suggestions->map( function ( SearchSuggestion $sugg ) {
649  return $sugg->getSuggestedTitle();
650  } ) );
651  $lb->setCaller( __METHOD__ );
652  $lb->execute();
653 
654  $diff = $suggestions->filter( function ( SearchSuggestion $sugg ) {
655  return $sugg->getSuggestedTitle()->isKnown();
656  } );
657  if ( $diff > 0 ) {
658  MediaWikiServices::getInstance()->getStatsdDataFactory()
659  ->updateCount( 'search.completion.missing', $diff );
660  }
661 
662  $results = $suggestions->map( function ( SearchSuggestion $sugg ) {
663  return $sugg->getSuggestedTitle()->getPrefixedText();
664  } );
665 
666  if ( $this->offset === 0 ) {
667  // Rescore results with an exact title match
668  // NOTE: in some cases like cross-namespace redirects
669  // (frequently used as shortcuts e.g. WP:WP on huwiki) some
670  // backends like Cirrus will return no results. We should still
671  // try an exact title match to workaround this limitation
672  $rescorer = new SearchExactMatchRescorer();
673  $rescoredResults = $rescorer->rescore( $search, $this->namespaces, $results, $this->limit );
674  } else {
675  // No need to rescore if offset is not 0
676  // The exact match must have been returned at position 0
677  // if it existed.
678  $rescoredResults = $results;
679  }
680 
681  if ( count( $rescoredResults ) > 0 ) {
682  $found = array_search( $rescoredResults[0], $results );
683  if ( $found === false ) {
684  // If the first result is not in the previous array it
685  // means that we found a new exact match
686  $exactMatch = SearchSuggestion::fromTitle( 0, Title::newFromText( $rescoredResults[0] ) );
687  $suggestions->prepend( $exactMatch );
688  $suggestions->shrink( $this->limit );
689  } else {
690  // if the first result is not the same we need to rescore
691  if ( $found > 0 ) {
692  $suggestions->rescore( $found );
693  }
694  }
695  }
696 
697  return $suggestions;
698  }
699 
705  public function defaultPrefixSearch( $search ) {
706  if ( trim( $search ) === '' ) {
707  return [];
708  }
709 
710  $search = $this->normalizeNamespaces( $search );
711  return $this->simplePrefixSearch( $search );
712  }
713 
720  protected function simplePrefixSearch( $search ) {
721  // Use default database prefix search
722  $backend = new TitlePrefixSearch;
723  return $backend->defaultSearchBackend( $this->namespaces, $search, $this->limit, $this->offset );
724  }
725 
742  public function getProfiles( $profileType, User $user = null ) {
743  return null;
744  }
745 
754  public function makeSearchFieldMapping( $name, $type ) {
755  return new NullIndexField();
756  }
757 
763  public function getSearchIndexFields() {
764  $models = MediaWikiServices::getInstance()->getContentHandlerFactory()->getContentModels();
765  $fields = [];
766  $seenHandlers = new SplObjectStorage();
767  foreach ( $models as $model ) {
768  try {
769  $handler = MediaWikiServices::getInstance()
770  ->getContentHandlerFactory()
771  ->getContentHandler( $model );
772  }
773  catch ( MWUnknownContentModelException $e ) {
774  // If we can find no handler, ignore it
775  continue;
776  }
777  // Several models can have the same handler, so avoid processing it repeatedly
778  if ( $seenHandlers->contains( $handler ) ) {
779  // We already did this one
780  continue;
781  }
782  $seenHandlers->attach( $handler );
783  $handlerFields = $handler->getFieldsForSearchIndex( $this );
784  foreach ( $handlerFields as $fieldName => $fieldData ) {
785  if ( empty( $fields[$fieldName] ) ) {
786  $fields[$fieldName] = $fieldData;
787  } else {
788  // TODO: do we allow some clashes with the same type or reject all of them?
789  $mergeDef = $fields[$fieldName]->merge( $fieldData );
790  if ( !$mergeDef ) {
791  throw new InvalidArgumentException( "Duplicate field $fieldName for model $model" );
792  }
793  $fields[$fieldName] = $mergeDef;
794  }
795  }
796  }
797  // Hook to allow extensions to produce search mapping fields
798  $this->getHookRunner()->onSearchIndexFields( $fields, $this );
799  return $fields;
800  }
801 
807  public function augmentSearchResults( ISearchResultSet $resultSet ) {
808  $setAugmentors = [];
809  $rowAugmentors = [];
810  $this->getHookRunner()->onSearchResultsAugment( $setAugmentors, $rowAugmentors );
811  if ( !$setAugmentors && !$rowAugmentors ) {
812  // We're done here
813  return;
814  }
815 
816  // Convert row augmentors to set augmentor
817  foreach ( $rowAugmentors as $name => $row ) {
818  if ( isset( $setAugmentors[$name] ) ) {
819  throw new InvalidArgumentException( "Both row and set augmentors are defined for $name" );
820  }
821  $setAugmentors[$name] = new PerRowAugmentor( $row );
822  }
823 
828  foreach ( $setAugmentors as $name => $augmentor ) {
829  $data = $augmentor->augmentAll( $resultSet );
830  if ( $data ) {
831  $resultSet->setAugmentedData( $name, $data );
832  }
833  }
834  }
835 
842  $this->hookContainer = $hookContainer;
843  $this->hookRunner = new HookRunner( $hookContainer );
844  }
845 
852  protected function getHookContainer() : HookContainer {
853  if ( !$this->hookContainer ) {
854  $this->hookContainer = MediaWikiServices::getInstance()->getHookContainer();
855  }
856  return $this->hookContainer;
857  }
858 
867  protected function getHookRunner() : HookRunner {
868  if ( !$this->hookRunner ) {
869  $this->hookRunner = new HookRunner( $this->getHookContainer() );
870  }
871  return $this->hookRunner;
872  }
873 
874 }
SearchEngine\$showSuggestion
bool $showSuggestion
Definition: SearchEngine.php:58
SearchSuggestionSet\fromStrings
static fromStrings(array $titles, $hasMoreResults=false)
Builds a new set of suggestion based on a string array.
Definition: SearchSuggestionSet.php:226
SearchEngine\getSearchIndexFields
getSearchIndexFields()
Get fields for search index.
Definition: SearchEngine.php:763
SearchEngine\getProfiles
getProfiles( $profileType, User $user=null)
Get a list of supported profiles.
Definition: SearchEngine.php:742
SearchEngine\getHookContainer
getHookContainer()
Get a HookContainer, for running extension hooks or for hook metadata.
Definition: SearchEngine.php:852
SearchSuggestionSet\map
map( $callback)
Call array_map on the suggestions array.
Definition: SearchSuggestionSet.php:85
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:332
SearchEngine\supports
supports( $feature)
Definition: SearchEngine.php:205
SearchEngine\augmentSearchResults
augmentSearchResults(ISearchResultSet $resultSet)
Augment search results with extra data.
Definition: SearchEngine.php:807
SearchEngine\setFeatureData
setFeatureData( $feature, $data)
Way to pass custom data for engines.
Definition: SearchEngine.php:221
SearchEngine\$limit
int $limit
Definition: SearchEngine.php:46
SearchEngine\getValidSorts
getValidSorts()
Get the valid sort directions.
Definition: SearchEngine.php:330
SearchEngine\$sort
$sort
Definition: SearchEngine.php:59
SearchHighlighter\DEFAULT_CONTEXT_CHARS
const DEFAULT_CONTEXT_CHARS
Definition: SearchHighlighter.php:33
SearchEngine\completionSearchWithVariants
completionSearchWithVariants( $search)
Perform a completion search with variants.
Definition: SearchEngine.php:597
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:35
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:146
TitlePrefixSearch
Performs prefix search, returning Title objects.
Definition: TitlePrefixSearch.php:28
SearchEngine\normalizeText
normalizeText( $string)
When overridden in derived class, performs database-specific conversions on text to be used for searc...
Definition: SearchEngine.php:244
SearchEngine\getSort
getSort()
Get the sort direction of the search results.
Definition: SearchEngine.php:356
SearchEngine\$namespaces
int[] null $namespaces
Definition: SearchEngine.php:43
SearchEngine\searchTitle
searchTitle( $term)
Perform a title-only search query and return a result set.
Definition: SearchEngine.php:149
SearchEngine\$searchTerms
string[] $searchTerms
Definition: SearchEngine.php:55
SearchEngine\userHighlightPrefs
static userHighlightPrefs()
Find snippet highlight settings for all users.
Definition: SearchEngine.php:450
SearchEngine\FT_QUERY_INDEP_PROFILE_TYPE
const FT_QUERY_INDEP_PROFILE_TYPE
Profile type for query independent ranking features.
Definition: SearchEngine.php:74
SearchEngine\completionSearchBackend
completionSearchBackend( $search)
Perform a completion search.
Definition: SearchEngine.php:558
SearchEngine\legalSearchChars
legalSearchChars( $type=self::CHARS_ALL)
Get chars legal for search.
Definition: SearchEngine.php:277
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1198
SearchSuggestionSet\prepend
prepend(SearchSuggestion $suggestion)
Add a new suggestion at the top.
Definition: SearchSuggestionSet.php:147
SearchEngine\parseNamespacePrefixes
static parseNamespacePrefixes( $query, $withAllKeyword=true, $withPrefixSearchExtractNamespaceHook=false)
Parse some common prefixes: all (search everything) or namespace names.
Definition: SearchEngine.php:388
SearchEngine\doSearchTitle
doSearchTitle( $term)
Perform a title-only search query and return a result set.
Definition: SearchEngine.php:162
SearchEngine\completionSearchBackendOverfetch
completionSearchBackendOverfetch( $search)
Perform an overfetch of completion search results.
Definition: SearchEngine.php:542
SearchEngine\setHookContainer
setHookContainer(HookContainer $hookContainer)
Definition: SearchEngine.php:841
SearchEngine\replacePrefixes
replacePrefixes( $query)
Parse some common prefixes: all (search everything) or namespace names and set the list of namespaces...
Definition: SearchEngine.php:369
SearchSuggestion\fromTitle
static fromTitle( $score, Title $title)
Create suggestion from Title.
Definition: SearchSuggestion.php:165
SearchEngine\DEFAULT_SORT
const DEFAULT_SORT
Definition: SearchEngine.php:37
SearchEngine\defaultPrefixSearch
defaultPrefixSearch( $search)
Simple prefix search for subpages.
Definition: SearchEngine.php:705
SearchEngine\COMPLETION_PROFILE_TYPE
const COMPLETION_PROFILE_TYPE
Profile type for completionSearch.
Definition: SearchEngine.php:71
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:42
NS_MAIN
const NS_MAIN
Definition: Defines.php:69
StatusValue\getValue
getValue()
Definition: StatusValue.php:137
SearchEngine\textAlreadyUpdatedForIndex
textAlreadyUpdatedForIndex()
If an implementation of SearchEngine handles all of its own text processing in getTextFromContent() a...
Definition: SearchEngine.php:516
SearchSuggestionSet\fromTitles
static fromTitles(array $titles, $hasMoreResults=false)
Builds a new set of suggestion based on a title array.
Definition: SearchSuggestionSet.php:209
Config
Interface for configuration instances.
Definition: Config.php:28
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:58
SearchEngine\setSort
setSort( $sort)
Set the sort direction of the search results.
Definition: SearchEngine.php:342
SearchExactMatchRescorer
An utility class to rescore search results by looking for an exact match in the db and add the page f...
Definition: SearchExactMatchRescorer.php:31
SearchNearMatcher
Implementation of near match title search.
Definition: SearchNearMatcher.php:11
SearchEngine\$offset
int $offset
Definition: SearchEngine.php:49
SearchEngine\CHARS_NO_SYNTAX
const CHARS_NO_SYNTAX
Integer flag for legalSearchChars: includes all chars allowed in a search term.
Definition: SearchEngine.php:80
SearchEngine\getNearMatcher
getNearMatcher(Config $config)
Get service class to finding near matches.
Definition: SearchEngine.php:254
SearchEngine\searchText
searchText( $term)
Perform a full text search query and return a result set.
Definition: SearchEngine.php:92
SearchSuggestion
Search suggestion.
Definition: SearchSuggestion.php:25
$title
$title
Definition: testCompression.php:38
PaginatingSearchEngine
Marker class for search engines that can handle their own pagination, by reporting in their ISearchRe...
Definition: PaginatingSearchEngine.php:11
ISearchResultSet\setAugmentedData
setAugmentedData( $name, $data)
Sets augmented data for result set.
SearchEngine\$prefix
string $prefix
Definition: SearchEngine.php:40
ISearchResultSet
A set of SearchEngine results.
Definition: ISearchResultSet.php:11
SearchEngine\updateTitle
updateTitle( $id, $title)
Update a search index record's title only.
Definition: SearchEngine.php:477
SearchEngine\setNamespaces
setNamespaces( $namespaces)
Set which namespaces the search should include.
Definition: SearchEngine.php:299
ResultSetAugmentor
Augment search results.
Definition: ResultSetAugmentor.php:6
SearchSuggestionSet\filter
filter( $callback)
Filter the suggestions array.
Definition: SearchSuggestionSet.php:95
SearchEngine\maybePaginate
maybePaginate(Closure $fn)
Performs an overfetch and shrink operation to determine if the next page is available for search engi...
Definition: SearchEngine.php:174
SearchEngine\update
update( $id, $title, $text)
Create or update the search index record for the given page.
Definition: SearchEngine.php:465
SearchHighlighter\DEFAULT_CONTEXT_LINES
const DEFAULT_CONTEXT_LINES
Definition: SearchHighlighter.php:32
SearchEngine\getTextFromContent
getTextFromContent(Title $t, Content $c=null)
Get the raw text for updating the index from a content object Nicer search backends could possibly do...
Definition: SearchEngine.php:504
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
SearchEngine\$hookRunner
HookRunner $hookRunner
Definition: SearchEngine.php:68
SearchSuggestionSet\shrink
shrink( $limit)
Remove any extra elements in the suggestions set.
Definition: SearchSuggestionSet.php:192
Hooks\runner
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:171
SearchEngine\getHookRunner
getHookRunner()
Get a HookRunner for running core hooks.
Definition: SearchEngine.php:867
SearchEngine\normalizeNamespaces
normalizeNamespaces( $search)
Makes search simple string if it was namespaced.
Definition: SearchEngine.php:526
SearchSuggestionSet\rescore
rescore( $key)
Move the suggestion at index $key to the first position.
Definition: SearchSuggestionSet.php:136
SearchEngine\setShowSuggestion
setShowSuggestion( $showSuggestion)
Set whether the searcher should try to build a suggestion.
Definition: SearchEngine.php:319
SearchEngine\doSearchArchiveTitle
doSearchArchiveTitle( $term)
Perform a title search in the article archive.
Definition: SearchEngine.php:134
SearchSuggestionSet
Search suggestion sets.
Definition: SearchSuggestionSet.php:26
SearchSuggestionSet\emptySuggestionSet
static emptySuggestionSet()
Definition: SearchSuggestionSet.php:237
SearchEngine
Contain a class for special pages.
Definition: SearchEngine.php:36
SearchEngine\defaultNearMatcher
static defaultNearMatcher()
Get near matcher for default SearchEngine.
Definition: SearchEngine.php:265
Content
Base interface for content objects.
Definition: Content.php:34
SearchEngine\completionSearch
completionSearch( $search)
Perform a completion search.
Definition: SearchEngine.php:583
SearchSuggestion\getSuggestedTitle
getSuggestedTitle()
Title object in the case this suggestion is based on a title.
Definition: SearchSuggestion.php:94
SearchEngine\doSearchText
doSearchText( $term)
Perform a full text search query and return a result set.
Definition: SearchEngine.php:105
PrefixSearch\defaultSearchBackend
defaultSearchBackend( $namespaces, $search, $limit, $offset)
Unless overridden by PrefixSearchBackend hook...
Definition: PrefixSearch.php:238
SearchEngine\makeSearchFieldMapping
makeSearchFieldMapping( $name, $type)
Create a search field definition.
Definition: SearchEngine.php:754
SearchEngine\simplePrefixSearch
simplePrefixSearch( $search)
Call out to simple search backend.
Definition: SearchEngine.php:720
Title
Represents a title within MediaWiki.
Definition: Title.php:42
NullIndexField
Null index field - means search engine does not implement this field.
Definition: NullIndexField.php:6
PerRowAugmentor
Perform augmentation of each row and return composite result, indexed by ID.
Definition: PerRowAugmentor.php:7
SearchEngine\extractTitles
extractTitles(SearchSuggestionSet $completionResults)
Extract titles from completion results.
Definition: SearchEngine.php:628
SearchEngine\CHARS_ALL
const CHARS_ALL
Integer flag for legalSearchChars: includes all chars allowed in a search query.
Definition: SearchEngine.php:77
MWUnknownContentModelException
Exception thrown when an unregistered content model is requested.
Definition: MWUnknownContentModelException.php:10
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:44
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:23
$t
$t
Definition: testCompression.php:74
SearchEngine\$hookContainer
HookContainer $hookContainer
Definition: SearchEngine.php:65
SearchEngine\$features
array $features
Feature values.
Definition: SearchEngine.php:62
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:55
SearchEngine\searchArchiveTitle
searchArchiveTitle( $term)
Perform a title search in the article archive.
Definition: SearchEngine.php:123
SearchEngine\setLimitOffset
setLimitOffset( $limit, $offset=0)
Set the maximum number of results to return and how many to skip before returning the first.
Definition: SearchEngine.php:288
SearchEngine\getFeatureData
getFeatureData( $feature)
Way to retrieve custom data set by setFeatureData or by the engine itself.
Definition: SearchEngine.php:232
SearchEngine\processCompletionResults
processCompletionResults( $search, SearchSuggestionSet $suggestions)
Process completion search results.
Definition: SearchEngine.php:641
$type
$type
Definition: testCompression.php:52