MediaWiki  master
SearchEngine.php
Go to the documentation of this file.
1 <?php
31 
37 abstract class SearchEngine {
38  public const DEFAULT_SORT = 'relevance';
39 
41  public $prefix = '';
42 
44  public $namespaces = [ NS_MAIN ];
45 
47  protected $limit = 10;
48 
50  protected $offset = 0;
51 
56  protected $searchTerms = [];
57 
59  protected $showSuggestion = true;
61 
63  protected $features = [];
64 
66  private $hookContainer;
67 
69  private $hookRunner;
70 
72  public const COMPLETION_PROFILE_TYPE = 'completionSearchProfile';
73 
75  public const FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile';
76 
78  protected const CHARS_ALL = 1;
79 
81  protected const CHARS_NO_SYNTAX = 2;
82 
93  public function searchText( $term ) {
94  return $this->maybePaginate( function () use ( $term ) {
95  return $this->doSearchText( $term );
96  } );
97  }
98 
108  protected function doSearchText( $term ) {
109  return null;
110  }
111 
126  public function searchArchiveTitle( $term ) {
127  return $this->doSearchArchiveTitle( $term );
128  }
129 
139  protected function doSearchArchiveTitle( $term ) {
140  return Status::newGood( [] );
141  }
142 
154  public function searchTitle( $term ) {
155  return $this->maybePaginate( function () use ( $term ) {
156  return $this->doSearchTitle( $term );
157  } );
158  }
159 
169  protected function doSearchTitle( $term ) {
170  return null;
171  }
172 
181  private function maybePaginate( Closure $fn ) {
182  if ( $this instanceof PaginatingSearchEngine ) {
183  return $fn();
184  }
185  $this->limit++;
186  try {
187  $resultSetOrStatus = $fn();
188  } finally {
189  $this->limit--;
190  }
191 
192  $resultSet = null;
193  if ( $resultSetOrStatus instanceof ISearchResultSet ) {
194  $resultSet = $resultSetOrStatus;
195  } elseif ( $resultSetOrStatus instanceof Status &&
196  $resultSetOrStatus->getValue() instanceof ISearchResultSet
197  ) {
198  $resultSet = $resultSetOrStatus->getValue();
199  }
200  if ( $resultSet ) {
201  $resultSet->shrink( $this->limit );
202  }
203 
204  return $resultSetOrStatus;
205  }
206 
214  public function supports( $feature ) {
215  switch ( $feature ) {
216  case 'search-update':
217  return true;
218  case 'title-suffix-filter':
219  default:
220  return false;
221  }
222  }
223 
230  public function setFeatureData( $feature, $data ) {
231  $this->features[$feature] = $data;
232  }
233 
241  public function getFeatureData( $feature ) {
242  return $this->features[$feature] ?? null;
243  }
244 
253  public function normalizeText( $string ) {
254  // Some languages such as Chinese require word segmentation
255  return MediaWikiServices::getInstance()->getContentLanguage()->segmentByWord( $string );
256  }
257 
263  public function getNearMatcher( Config $config ) {
264  return new SearchNearMatcher( $config,
265  MediaWikiServices::getInstance()->getContentLanguage(),
266  $this->getHookContainer()
267  );
268  }
269 
274  protected static function defaultNearMatcher() {
275  $services = MediaWikiServices::getInstance();
276  $config = $services->getMainConfig();
277  return $services->newSearchEngine()->getNearMatcher( $config );
278  }
279 
286  public function legalSearchChars( $type = self::CHARS_ALL ) {
287  return "A-Za-z_'.0-9\\x80-\\xFF\\-";
288  }
289 
297  public function setLimitOffset( $limit, $offset = 0 ) {
298  $this->limit = intval( $limit );
299  $this->offset = intval( $offset );
300  }
301 
308  public function setNamespaces( $namespaces ) {
309  if ( $namespaces ) {
310  // Filter namespaces to only keep valid ones
311  $validNs = MediaWikiServices::getInstance()->getSearchEngineConfig()->searchableNamespaces();
312  $namespaces = array_filter( $namespaces, function ( $ns ) use( $validNs ) {
313  return $ns < 0 || isset( $validNs[$ns] );
314  } );
315  } else {
316  $namespaces = [];
317  }
318  $this->namespaces = $namespaces;
319  }
320 
328  public function setShowSuggestion( $showSuggestion ) {
329  $this->showSuggestion = $showSuggestion;
330  }
331 
341  public function getValidSorts() {
342  return [ self::DEFAULT_SORT ];
343  }
344 
353  public function setSort( $sort ) {
354  if ( !in_array( $sort, $this->getValidSorts() ) ) {
355  throw new InvalidArgumentException( "Invalid sort: $sort. " .
356  "Must be one of: " . implode( ', ', $this->getValidSorts() ) );
357  }
358  $this->sort = $sort;
359  }
360 
367  public function getSort() {
368  return $this->sort;
369  }
370 
380  public function replacePrefixes( $query ) {
381  return $query;
382  }
383 
399  public static function parseNamespacePrefixes(
400  $query,
401  $withAllKeyword = true,
402  $withPrefixSearchExtractNamespaceHook = false
403  ) {
404  $parsed = $query;
405  if ( strpos( $query, ':' ) === false ) { // nothing to do
406  return false;
407  }
408  $extractedNamespace = null;
409 
410  $allQuery = false;
411  if ( $withAllKeyword ) {
412  $allkeywords = [];
413 
414  $allkeywords[] = wfMessage( 'searchall' )->inContentLanguage()->text() . ":";
415  // force all: so that we have a common syntax for all the wikis
416  if ( !in_array( 'all:', $allkeywords ) ) {
417  $allkeywords[] = 'all:';
418  }
419 
420  foreach ( $allkeywords as $kw ) {
421  if ( strncmp( $query, $kw, strlen( $kw ) ) == 0 ) {
422  $extractedNamespace = null;
423  $parsed = substr( $query, strlen( $kw ) );
424  $allQuery = true;
425  break;
426  }
427  }
428  }
429 
430  if ( !$allQuery && strpos( $query, ':' ) !== false ) {
431  $prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
432  $index = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $prefix );
433  if ( $index !== false ) {
434  $extractedNamespace = [ $index ];
435  $parsed = substr( $query, strlen( $prefix ) + 1 );
436  } elseif ( $withPrefixSearchExtractNamespaceHook ) {
437  $hookNamespaces = [ NS_MAIN ];
438  $hookQuery = $query;
439  Hooks::runner()->onPrefixSearchExtractNamespace( $hookNamespaces, $hookQuery );
440  if ( $hookQuery !== $query ) {
441  $parsed = $hookQuery;
442  $extractedNamespace = $hookNamespaces;
443  } else {
444  return false;
445  }
446  } else {
447  return false;
448  }
449  }
450 
451  return [ $parsed, $extractedNamespace ];
452  }
453 
461  public static function userHighlightPrefs() {
464  return [ $contextlines, $contextchars ];
465  }
466 
476  public function update( $id, $title, $text ) {
477  // no-op
478  }
479 
488  public function updateTitle( $id, $title ) {
489  // no-op
490  }
491 
500  public function delete( $id, $title ) {
501  // no-op
502  }
503 
515  public function getTextFromContent( Title $t, Content $c = null ) {
516  return $c ? $c->getTextForSearchIndex() : '';
517  }
518 
527  public function textAlreadyUpdatedForIndex() {
528  return false;
529  }
530 
537  protected function normalizeNamespaces( $search ) {
538  $queryAndNs = self::parseNamespacePrefixes( $search, false, true );
539  if ( $queryAndNs !== false ) {
540  $this->setNamespaces( $queryAndNs[1] );
541  return $queryAndNs[0];
542  }
543  return $search;
544  }
545 
553  protected function completionSearchBackendOverfetch( $search ) {
554  $this->limit++;
555  try {
556  return $this->completionSearchBackend( $search );
557  } finally {
558  $this->limit--;
559  }
560  }
561 
572  protected function completionSearchBackend( $search ) {
573  $results = [];
574 
575  $search = trim( $search );
576 
577  if ( !in_array( NS_SPECIAL, $this->namespaces ) && // We do not run hook on Special: search
578  !$this->getHookRunner()->onPrefixSearchBackend(
579  $this->namespaces, $search, $this->limit, $results, $this->offset )
580  ) {
581  // False means hook worked.
582  // FIXME: Yes, the API is weird. That's why it is going to be deprecated.
583 
584  return SearchSuggestionSet::fromStrings( $results );
585  } else {
586  // Hook did not do the job, use default simple search
587  $results = $this->simplePrefixSearch( $search );
588  return SearchSuggestionSet::fromTitles( $results );
589  }
590  }
591 
597  public function completionSearch( $search ) {
598  if ( trim( $search ) === '' ) {
599  return SearchSuggestionSet::emptySuggestionSet(); // Return empty result
600  }
601  $search = $this->normalizeNamespaces( $search );
602  $suggestions = $this->completionSearchBackendOverfetch( $search );
603  return $this->processCompletionResults( $search, $suggestions );
604  }
605 
613  public function completionSearchWithVariants( $search ) {
614  if ( trim( $search ) === '' ) {
615  return SearchSuggestionSet::emptySuggestionSet(); // Return empty result
616  }
617  $search = $this->normalizeNamespaces( $search );
618 
619  $results = $this->completionSearchBackendOverfetch( $search );
620  $fallbackLimit = 1 + $this->limit - $results->getSize();
621  if ( $fallbackLimit > 0 ) {
622  $fallbackSearches = MediaWikiServices::getInstance()->getContentLanguage()->
623  autoConvertToAllVariants( $search );
624  $fallbackSearches = array_diff( array_unique( $fallbackSearches ), [ $search ] );
625 
626  foreach ( $fallbackSearches as $fbs ) {
627  $this->setLimitOffset( $fallbackLimit );
628  $fallbackSearchResult = $this->completionSearch( $fbs );
629  $results->appendAll( $fallbackSearchResult );
630  $fallbackLimit -= $fallbackSearchResult->getSize();
631  if ( $fallbackLimit <= 0 ) {
632  break;
633  }
634  }
635  }
636  return $this->processCompletionResults( $search, $results );
637  }
638 
644  public function extractTitles( SearchSuggestionSet $completionResults ) {
645  return $completionResults->map( function ( SearchSuggestion $sugg ) {
646  return $sugg->getSuggestedTitle();
647  } );
648  }
649 
657  protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
658  // We over-fetched to determine pagination. Shrink back down if we have extra results
659  // and mark if pagination is possible
660  $suggestions->shrink( $this->limit );
661 
662  $search = trim( $search );
663  // preload the titles with LinkBatch
664  $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
665  $lb = $linkBatchFactory->newLinkBatch( $suggestions->map( function ( SearchSuggestion $sugg ) {
666  return $sugg->getSuggestedTitle();
667  } ) );
668  $lb->setCaller( __METHOD__ );
669  $lb->execute();
670 
671  $diff = $suggestions->filter( function ( SearchSuggestion $sugg ) {
672  return $sugg->getSuggestedTitle()->isKnown();
673  } );
674  if ( $diff > 0 ) {
675  MediaWikiServices::getInstance()->getStatsdDataFactory()
676  ->updateCount( 'search.completion.missing', $diff );
677  }
678 
679  $results = $suggestions->map( function ( SearchSuggestion $sugg ) {
680  return $sugg->getSuggestedTitle()->getPrefixedText();
681  } );
682 
683  if ( $this->offset === 0 ) {
684  // Rescore results with an exact title match
685  // NOTE: in some cases like cross-namespace redirects
686  // (frequently used as shortcuts e.g. WP:WP on huwiki) some
687  // backends like Cirrus will return no results. We should still
688  // try an exact title match to workaround this limitation
689  $rescorer = new SearchExactMatchRescorer();
690  $rescoredResults = $rescorer->rescore( $search, $this->namespaces, $results, $this->limit );
691  } else {
692  // No need to rescore if offset is not 0
693  // The exact match must have been returned at position 0
694  // if it existed.
695  $rescoredResults = $results;
696  }
697 
698  if ( count( $rescoredResults ) > 0 ) {
699  $found = array_search( $rescoredResults[0], $results );
700  if ( $found === false ) {
701  // If the first result is not in the previous array it
702  // means that we found a new exact match
703  $exactMatch = SearchSuggestion::fromTitle( 0, Title::newFromText( $rescoredResults[0] ) );
704  $suggestions->prepend( $exactMatch );
705  $suggestions->shrink( $this->limit );
706  } else {
707  // if the first result is not the same we need to rescore
708  if ( $found > 0 ) {
709  $suggestions->rescore( $found );
710  }
711  }
712  }
713 
714  return $suggestions;
715  }
716 
722  public function defaultPrefixSearch( $search ) {
723  if ( trim( $search ) === '' ) {
724  return [];
725  }
726 
727  $search = $this->normalizeNamespaces( $search );
728  return $this->simplePrefixSearch( $search );
729  }
730 
737  protected function simplePrefixSearch( $search ) {
738  // Use default database prefix search
739  $backend = new TitlePrefixSearch;
740  return $backend->defaultSearchBackend( $this->namespaces, $search, $this->limit, $this->offset );
741  }
742 
761  public function getProfiles( $profileType, User $user = null ) {
762  return null;
763  }
764 
775  public function makeSearchFieldMapping( $name, $type ) {
776  return new NullIndexField();
777  }
778 
784  public function getSearchIndexFields() {
785  $models = MediaWikiServices::getInstance()->getContentHandlerFactory()->getContentModels();
786  $fields = [];
787  $seenHandlers = new SplObjectStorage();
788  foreach ( $models as $model ) {
789  try {
790  $handler = MediaWikiServices::getInstance()
791  ->getContentHandlerFactory()
792  ->getContentHandler( $model );
793  }
794  catch ( MWUnknownContentModelException $e ) {
795  // If we can find no handler, ignore it
796  continue;
797  }
798  // Several models can have the same handler, so avoid processing it repeatedly
799  if ( $seenHandlers->contains( $handler ) ) {
800  // We already did this one
801  continue;
802  }
803  $seenHandlers->attach( $handler );
804  $handlerFields = $handler->getFieldsForSearchIndex( $this );
805  foreach ( $handlerFields as $fieldName => $fieldData ) {
806  if ( empty( $fields[$fieldName] ) ) {
807  $fields[$fieldName] = $fieldData;
808  } else {
809  // TODO: do we allow some clashes with the same type or reject all of them?
810  $mergeDef = $fields[$fieldName]->merge( $fieldData );
811  if ( !$mergeDef ) {
812  throw new InvalidArgumentException( "Duplicate field $fieldName for model $model" );
813  }
814  $fields[$fieldName] = $mergeDef;
815  }
816  }
817  }
818  // Hook to allow extensions to produce search mapping fields
819  $this->getHookRunner()->onSearchIndexFields( $fields, $this );
820  return $fields;
821  }
822 
828  public function augmentSearchResults( ISearchResultSet $resultSet ) {
829  $setAugmentors = [];
830  $rowAugmentors = [];
831  $this->getHookRunner()->onSearchResultsAugment( $setAugmentors, $rowAugmentors );
832  if ( !$setAugmentors && !$rowAugmentors ) {
833  // We're done here
834  return;
835  }
836 
837  // Convert row augmentors to set augmentor
838  foreach ( $rowAugmentors as $name => $row ) {
839  if ( isset( $setAugmentors[$name] ) ) {
840  throw new InvalidArgumentException( "Both row and set augmentors are defined for $name" );
841  }
842  $setAugmentors[$name] = new PerRowAugmentor( $row );
843  }
844 
849  foreach ( $setAugmentors as $name => $augmentor ) {
850  $data = $augmentor->augmentAll( $resultSet );
851  if ( $data ) {
852  $resultSet->setAugmentedData( $name, $data );
853  }
854  }
855  }
856 
863  $this->hookContainer = $hookContainer;
864  $this->hookRunner = new HookRunner( $hookContainer );
865  }
866 
873  protected function getHookContainer() : HookContainer {
874  if ( !$this->hookContainer ) {
875  // This shouldn't be hit in core, but it is needed for CirrusSearch
876  // which commonly creates a CirrusSearch object without cirrus being
877  // configured in $wgSearchType/$wgSearchTypeAlternatives.
878  $this->hookContainer = MediaWikiServices::getInstance()->getHookContainer();
879  }
880  return $this->hookContainer;
881  }
882 
891  protected function getHookRunner() : HookRunner {
892  if ( !$this->hookRunner ) {
893  $this->hookRunner = new HookRunner( $this->getHookContainer() );
894  }
895  return $this->hookRunner;
896  }
897 
898 }
SearchEngine\$showSuggestion
bool $showSuggestion
Definition: SearchEngine.php:59
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:784
SearchEngine\getProfiles
getProfiles( $profileType, User $user=null)
Get a list of supported profiles.
Definition: SearchEngine.php:761
SearchEngine\getHookContainer
getHookContainer()
Get a HookContainer, for running extension hooks or for hook metadata.
Definition: SearchEngine.php:873
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:328
SearchEngine\supports
supports( $feature)
Definition: SearchEngine.php:214
SearchEngine\augmentSearchResults
augmentSearchResults(ISearchResultSet $resultSet)
Augment search results with extra data.
Definition: SearchEngine.php:828
SearchEngine\setFeatureData
setFeatureData( $feature, $data)
Way to pass custom data for engines.
Definition: SearchEngine.php:230
SearchEngine\$limit
int $limit
Definition: SearchEngine.php:47
SearchEngine\getValidSorts
getValidSorts()
Get the valid sort directions.
Definition: SearchEngine.php:341
SearchEngine\$sort
$sort
Definition: SearchEngine.php:60
SearchHighlighter\DEFAULT_CONTEXT_CHARS
const DEFAULT_CONTEXT_CHARS
Definition: SearchHighlighter.php:36
SearchEngine\completionSearchWithVariants
completionSearchWithVariants( $search)
Perform a completion search with variants.
Definition: SearchEngine.php:613
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:165
TitlePrefixSearch
Performs prefix search, returning Title objects.
Definition: TitlePrefixSearch.php:30
SearchEngine\normalizeText
normalizeText( $string)
When overridden in derived class, performs database-specific conversions on text to be used for searc...
Definition: SearchEngine.php:253
SearchEngine\getSort
getSort()
Get the sort direction of the search results.
Definition: SearchEngine.php:367
SearchEngine\$namespaces
int[] null $namespaces
Definition: SearchEngine.php:44
SearchEngine\searchTitle
searchTitle( $term)
Perform a title-only search query and return a result set.
Definition: SearchEngine.php:154
SearchEngine\$searchTerms
string[] $searchTerms
Definition: SearchEngine.php:56
SearchEngine\userHighlightPrefs
static userHighlightPrefs()
Find snippet highlight settings for all users.
Definition: SearchEngine.php:461
SearchEngine\FT_QUERY_INDEP_PROFILE_TYPE
const FT_QUERY_INDEP_PROFILE_TYPE
Profile type for query independent ranking features.
Definition: SearchEngine.php:75
SearchEngine\completionSearchBackend
completionSearchBackend( $search)
Perform a completion search.
Definition: SearchEngine.php:572
SearchEngine\legalSearchChars
legalSearchChars( $type=self::CHARS_ALL)
Get chars legal for search.
Definition: SearchEngine.php:286
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
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:399
SearchEngine\doSearchTitle
doSearchTitle( $term)
Perform a title-only search query and return a result set.
Definition: SearchEngine.php:169
SearchEngine\completionSearchBackendOverfetch
completionSearchBackendOverfetch( $search)
Perform an overfetch of completion search results.
Definition: SearchEngine.php:553
SearchEngine\setHookContainer
setHookContainer(HookContainer $hookContainer)
Definition: SearchEngine.php:862
SearchEngine\replacePrefixes
replacePrefixes( $query)
Parse some common prefixes: all (search everything) or namespace names and set the list of namespaces...
Definition: SearchEngine.php:380
SearchSuggestion\fromTitle
static fromTitle( $score, Title $title)
Create suggestion from Title.
Definition: SearchSuggestion.php:163
SearchEngine\DEFAULT_SORT
const DEFAULT_SORT
Definition: SearchEngine.php:38
SearchEngine\defaultPrefixSearch
defaultPrefixSearch( $search)
Simple prefix search for subpages.
Definition: SearchEngine.php:722
SearchEngine\COMPLETION_PROFILE_TYPE
const COMPLETION_PROFILE_TYPE
Profile type for completionSearch.
Definition: SearchEngine.php:72
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:44
NS_MAIN
const NS_MAIN
Definition: Defines.php:69
StatusValue\getValue
getValue()
Definition: StatusValue.php:138
SearchEngine\textAlreadyUpdatedForIndex
textAlreadyUpdatedForIndex()
If an implementation of SearchEngine handles all of its own text processing in getTextFromContent() a...
Definition: SearchEngine.php:527
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:30
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:58
SearchEngine\setSort
setSort( $sort)
Set the sort direction of the search results.
Definition: SearchEngine.php:353
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:33
SearchNearMatcher
Implementation of near match title search.
Definition: SearchNearMatcher.php:12
SearchEngine\$offset
int $offset
Definition: SearchEngine.php:50
SearchEngine\CHARS_NO_SYNTAX
const CHARS_NO_SYNTAX
Integer flag for legalSearchChars: includes all chars allowed in a search term.
Definition: SearchEngine.php:81
SearchEngine\getNearMatcher
getNearMatcher(Config $config)
Get service class to finding near matches.
Definition: SearchEngine.php:263
SearchEngine\searchText
searchText( $term)
Perform a full text search query and return a result set.
Definition: SearchEngine.php:93
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:13
ISearchResultSet\setAugmentedData
setAugmentedData( $name, $data)
Sets augmented data for result set.
SearchEngine\$prefix
string $prefix
Definition: SearchEngine.php:41
ISearchResultSet
A set of SearchEngine results.
Definition: ISearchResultSet.php:12
SearchEngine\updateTitle
updateTitle( $id, $title)
Update a search index record's title only.
Definition: SearchEngine.php:488
SearchEngine\setNamespaces
setNamespaces( $namespaces)
Set which namespaces the search should include.
Definition: SearchEngine.php:308
ResultSetAugmentor
Augment search results.
Definition: ResultSetAugmentor.php:7
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:181
SearchEngine\update
update( $id, $title, $text)
Create or update the search index record for the given page.
Definition: SearchEngine.php:476
SearchHighlighter\DEFAULT_CONTEXT_LINES
const DEFAULT_CONTEXT_LINES
Definition: SearchHighlighter.php:35
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:515
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
SearchEngine\$hookRunner
HookRunner $hookRunner
Definition: SearchEngine.php:69
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:172
SearchEngine\getHookRunner
getHookRunner()
Get a HookRunner for running core hooks.
Definition: SearchEngine.php:891
SearchEngine\normalizeNamespaces
normalizeNamespaces( $search)
Makes search simple string if it was namespaced.
Definition: SearchEngine.php:537
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:328
SearchEngine\doSearchArchiveTitle
doSearchArchiveTitle( $term)
Perform a title search in the article archive.
Definition: SearchEngine.php:139
SearchSuggestionSet
Search suggestion sets.
Definition: SearchSuggestionSet.php:26
SearchSuggestionSet\emptySuggestionSet
static emptySuggestionSet()
Definition: SearchSuggestionSet.php:237
SearchEngine
Contain a class for special pages Stable to extend.
Definition: SearchEngine.php:37
SearchEngine\defaultNearMatcher
static defaultNearMatcher()
Get near matcher for default SearchEngine.
Definition: SearchEngine.php:274
Content
Base interface for content objects.
Definition: Content.php:35
SearchEngine\completionSearch
completionSearch( $search)
Perform a completion search.
Definition: SearchEngine.php:597
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:108
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:775
SearchEngine\simplePrefixSearch
simplePrefixSearch( $search)
Call out to simple search backend.
Definition: SearchEngine.php:737
Title
Represents a title within MediaWiki.
Definition: Title.php:41
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:644
SearchEngine\CHARS_ALL
const CHARS_ALL
Integer flag for legalSearchChars: includes all chars allowed in a search query.
Definition: SearchEngine.php:78
MWUnknownContentModelException
Exception thrown when an unregistered content model is requested.
Definition: MWUnknownContentModelException.php:11
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:567
$t
$t
Definition: testCompression.php:74
SearchEngine\$hookContainer
HookContainer $hookContainer
Definition: SearchEngine.php:66
SearchEngine\$features
array $features
Feature values.
Definition: SearchEngine.php:63
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
SearchEngine\searchArchiveTitle
searchArchiveTitle( $term)
Perform a title search in the article archive.
Definition: SearchEngine.php:126
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:297
SearchEngine\getFeatureData
getFeatureData( $feature)
Way to retrieve custom data set by setFeatureData or by the engine itself.
Definition: SearchEngine.php:241
SearchEngine\processCompletionResults
processCompletionResults( $search, SearchSuggestionSet $suggestions)
Process completion search results.
Definition: SearchEngine.php:657
$type
$type
Definition: testCompression.php:52