BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
SearchEngine Class Reference
Inheritance diagram for SearchEngine:
Collaboration diagram for SearchEngine:

Public Member Functions

 searchText ($term)
 
 searchArchiveTitle ($term)
 
 searchTitle ($term)
 
 supports ($feature)
 
 setFeatureData ($feature, $data)
 
 getFeatureData ($feature)
 
 normalizeText ($string)
 
 transformSearchTerm ($term)
 
 getNearMatcher (Config $config)
 
 setLimitOffset ($limit, $offset=0)
 
 setNamespaces ($namespaces)
 
 setShowSuggestion ($showSuggestion)
 
 getValidSorts ()
 
 setSort ($sort)
 
 getSort ()
 
 replacePrefixes ($query)
 
 update ($id, $title, $text)
 
 updateTitle ($id, $title)
 
 delete ($id, $title)
 
 getTextFromContent (Title $t, Content $c=null)
 
 textAlreadyUpdatedForIndex ()
 
 completionSearch ($search)
 
 completionSearchWithVariants ($search)
 
 extractTitles (SearchSuggestionSet $completionResults)
 
 defaultPrefixSearch ($search)
 
 getProfiles ($profileType, User $user=null)
 
 makeSearchFieldMapping ($name, $type)
 
 getSearchIndexFields ()
 
 augmentSearchResults (SearchResultSet $resultSet)
 

Static Public Member Functions

static getNearMatch ($searchterm)
 
static getNearMatchResultSet ($searchterm)
 
static legalSearchChars ($type=self::CHARS_ALL)
 
static parseNamespacePrefixes ($query)
 
static userHighlightPrefs ()
 
static searchableNamespaces ()
 
static userNamespaces ($user)
 
static defaultNamespaces ()
 
static namespacesAsText ($namespaces)
 
static create ($type=null)
 
static getSearchTypes ()
 

Public Attributes

 $prefix = ''
 
 $namespaces = [ NS_MAIN ]
 
const COMPLETION_PROFILE_TYPE = 'completionSearchProfile'
 
const FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile'
 
const CHARS_ALL = 1
 
const CHARS_NO_SYNTAX = 2
 

Protected Member Functions

 normalizeNamespaces ($search)
 
 completionSearchBackend ($search)
 
 processCompletionResults ($search, SearchSuggestionSet $suggestions)
 
 simplePrefixSearch ($search)
 

Static Protected Member Functions

static defaultNearMatcher ()
 

Protected Attributes

 $limit = 10
 
 $offset = 0
 
 $searchTerms = []
 
 $showSuggestion = true
 
 $features = []
 

Detailed Description

Contain a class for special pages

Member Function Documentation

SearchEngine::augmentSearchResults ( SearchResultSet  $resultSet)

Augment search results with extra data.

Parameters
SearchResultSet$resultSet
SearchEngine::completionSearch (   $search)

Perform a completion search.

Parameters
string$search
Returns
SearchSuggestionSet
SearchEngine::completionSearchBackend (   $search)
protected

Perform a completion search. Does not resolve namespaces and does not check variants. Search engine implementations may want to override this function.

Parameters
string$search
Returns
SearchSuggestionSet
SearchEngine::completionSearchWithVariants (   $search)

Perform a completion search with variants.

Parameters
string$search
Returns
SearchSuggestionSet
static SearchEngine::create (   $type = null)
static

Load up the appropriate search engine class for the currently active database backend, and return a configured instance.

Deprecated:
since 1.27; Use SearchEngineFactory::create
Parameters
string$typeType of search backend, if not the default
Returns
SearchEngine
static SearchEngine::defaultNamespaces ( )
static

An array of namespaces indexes to be searched by default

Deprecated:
since 1.27; use SearchEngineConfig::defaultNamespaces()
Returns
array
static SearchEngine::defaultNearMatcher ( )
staticprotected

Get near matcher for default SearchEngine.

Returns
SearchNearMatcher
SearchEngine::defaultPrefixSearch (   $search)

Simple prefix search for subpages.

Parameters
string$search
Returns
Title[]
SearchEngine::delete (   $id,
  $title 
)

Delete an indexed page Title should be pre-processed. STUB

Parameters
int$idPage id that was deleted
string$titleTitle of page that was deleted
SearchEngine::extractTitles ( SearchSuggestionSet  $completionResults)

Extract titles from completion results

Parameters
SearchSuggestionSet$completionResults
Returns
Title[]
SearchEngine::getFeatureData (   $feature)

Way to retrieve custom data set by setFeatureData or by the engine itself.

Since
1.29
Parameters
string$featurefeature name
Returns
mixed the feature value or null if unset
static SearchEngine::getNearMatch (   $searchterm)
static

If an exact title match can be found, or a very slightly close match, return the title. If no match, returns NULL.

Deprecated:
since 1.27; Use SearchEngine::getNearMatcher()
Parameters
string$searchterm
Returns
Title
SearchEngine::getNearMatcher ( Config  $config)

Get service class to finding near matches.

Parameters
Config$configConfiguration to use for the matcher.
Returns
SearchNearMatcher
static SearchEngine::getNearMatchResultSet (   $searchterm)
static

Do a near match (see SearchEngine::getNearMatch) and wrap it into a SearchResultSet.

Deprecated:
since 1.27; Use SearchEngine::getNearMatcher()
Parameters
string$searchterm
Returns
SearchResultSet
SearchEngine::getProfiles (   $profileType,
User  $user = null 
)

Get a list of supported profiles. Some search engine implementations may expose specific profiles to fine-tune its behaviors. The profile can be passed as a feature data with setFeatureData( $profileType, $profileName ) The array returned by this function contains the following keys:

  • name: the profile name to use with setFeatureData
  • desc-message: the i18n description
  • default: set to true if this profile is the default
Since
1.28
Parameters
string$profileTypethe type of profiles
User | null$userthe user requesting the list of profiles
Returns
array|null the list of profiles or null if none available
SearchEngine::getSearchIndexFields ( )

Get fields for search index

Since
1.28
Returns
SearchIndexField[] Index field definitions for all content handlers
static SearchEngine::getSearchTypes ( )
static

Return the search engines we support. If only $wgSearchType is set, it'll be an array of just that one item.

Deprecated:
since 1.27; use SearchEngineConfig::getSearchTypes()
Returns
array
SearchEngine::getSort ( )

Get the sort direction of the search results

Since
1.25
Returns
string
SearchEngine::getTextFromContent ( Title  $t,
Content  $c = null 
)

Get the raw text for updating the index from a content object Nicer search backends could possibly do something cooler than just returning raw text

Todo:
This isn't ideal, we'd really like to have content-specific handling here
Parameters
Title$tTitle we're indexing
Content$cContent of the page to index
Returns
string
SearchEngine::getValidSorts ( )

Get the valid sort directions. All search engines support 'relevance' but others might support more. The default in all implementations should be 'relevance.'

Since
1.25
Returns
string[] the valid sort directions for setSort
static SearchEngine::legalSearchChars (   $type = self::CHARS_ALL)
static

Get chars legal for search NOTE: usage as static is deprecated and preserved only as BC measure

Parameters
int$typetype of search chars (see self::CHARS_ALL and self::CHARS_NO_SYNTAX). Defaults to CHARS_ALL
Returns
string
SearchEngine::makeSearchFieldMapping (   $name,
  $type 
)

Create a search field definition. Specific search engines should override this method to create search fields.

Parameters
string$name
int$typeOne of the types in SearchIndexField::INDEX_TYPE_*
Returns
SearchIndexField
Since
1.28
static SearchEngine::namespacesAsText (   $namespaces)
static

Get a list of namespace names useful for showing in tooltips and preferences

Deprecated:
since 1.27; use SearchEngineConfig::namespacesAsText()
Parameters
array$namespaces
Returns
array
SearchEngine::normalizeNamespaces (   $search)
protected

Makes search simple string if it was namespaced. Sets namespaces of the search to namespaces extracted from string.

Parameters
string$search
Returns
string Simplified search string
SearchEngine::normalizeText (   $string)

When overridden in derived class, performs database-specific conversions on text to be used for searching or updating search index. Default implementation does nothing (simply returns $string).

Parameters
string$stringString to process
Returns
string
static SearchEngine::parseNamespacePrefixes (   $query)
static

Parse some common prefixes: all (search everything) or namespace names

Parameters
string$query
Returns
false|array false if no namespace was extracted, an array with the parsed query at index 0 and an array of namespaces at index 1 (or null for all namespaces).
SearchEngine::processCompletionResults (   $search,
SearchSuggestionSet  $suggestions 
)
protected

Process completion search results. Resolves the titles and rescores.

Parameters
string$search
SearchSuggestionSet$suggestions
Returns
SearchSuggestionSet
SearchEngine::replacePrefixes (   $query)

Parse some common prefixes: all (search everything) or namespace names and set the list of namespaces of this class accordingly.

Parameters
string$query
Returns
string
static SearchEngine::searchableNamespaces ( )
static

Make a list of searchable namespaces and their canonical names.

Deprecated:
since 1.27; use SearchEngineConfig::searchableNamespaces()
Returns
array
SearchEngine::searchArchiveTitle (   $term)

Perform a title search in the article archive. NOTE: these results still should be filtered by matching against PageArchive, permissions checks etc The results returned by this methods are only sugegstions and may not end up being shown to the user.

Parameters
string$termRaw search term
Returns
Status<Title[]>
Since
1.29
SearchEngine::searchText (   $term)

Perform a full text search query and return a result set. If full text searches are not supported or disabled, return null. STUB

Parameters
string$termRaw search term
Returns
SearchResultSet|Status|null
SearchEngine::searchTitle (   $term)

Perform a title-only search query and return a result set. If title searches are not supported or disabled, return null. STUB

Parameters
string$termRaw search term
Returns
SearchResultSet|null
SearchEngine::setFeatureData (   $feature,
  $data 
)

Way to pass custom data for engines

Since
1.18
Parameters
string$feature
mixed$data
SearchEngine::setLimitOffset (   $limit,
  $offset = 0 
)

Set the maximum number of results to return and how many to skip before returning the first.

Parameters
int$limit
int$offset
SearchEngine::setNamespaces (   $namespaces)

Set which namespaces the search should include. Give an array of namespace index numbers.

Parameters
int[]|null$namespaces
SearchEngine::setShowSuggestion (   $showSuggestion)

Set whether the searcher should try to build a suggestion. Note: some searchers don't support building a suggestion in the first place and others don't respect this flag.

Parameters
bool$showSuggestionShould the searcher try to build suggestions
SearchEngine::setSort (   $sort)

Set the sort direction of the search results. Must be one returned by SearchEngine::getValidSorts()

Since
1.25
Exceptions
InvalidArgumentException
Parameters
string$sortsort direction for query result
SearchEngine::simplePrefixSearch (   $search)
protected

Call out to simple search backend. Defaults to TitlePrefixSearch.

Parameters
string$search
Returns
Title[]
SearchEngine::supports (   $feature)
Since
1.18
Parameters
string$feature
Returns
bool
SearchEngine::textAlreadyUpdatedForIndex ( )

If an implementation of SearchEngine handles all of its own text processing in getTextFromContent() and doesn't require SearchUpdate::updateText()'s rather silly handling, it should return true here instead.

Returns
bool
SearchEngine::transformSearchTerm (   $term)

Transform search term in cases when parts of the query came as different GET params (when supported), e.g. for prefix queries: search=test&prefix=Main_Page/Archive -> test prefix:Main Page/Archive

Parameters
string$term
Returns
string
SearchEngine::update (   $id,
  $title,
  $text 
)

Create or update the search index record for the given page. Title and text should be pre-processed. STUB

Parameters
int$id
string$title
string$text
SearchEngine::updateTitle (   $id,
  $title 
)

Update a search index record's title only. Title should be pre-processed. STUB

Parameters
int$id
string$title
static SearchEngine::userHighlightPrefs ( )
static

Find snippet highlight settings for all users

Returns
array Contextlines, contextchars
static SearchEngine::userNamespaces (   $user)
static

Extract default namespaces to search from the given user's settings, returning a list of index numbers.

Deprecated:
since 1.27; use SearchEngineConfig::userNamespaces()
Parameters
user$user
Returns
array

Member Data Documentation

const SearchEngine::CHARS_ALL = 1

int flag for legalSearchChars: includes all chars allowed in a search query

const SearchEngine::CHARS_NO_SYNTAX = 2

int flag for legalSearchChars: includes all chars allowed in a search term

const SearchEngine::COMPLETION_PROFILE_TYPE = 'completionSearchProfile'

string profile type for completionSearch

const SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile'

string profile type for query independent ranking features


The documentation for this class was generated from the following file: