CirrusSearch
Elasticsearch-powered search for MediaWiki
|
SearchEngine implementation for CirrusSearch. More...
Public Member Functions | |
__construct (SearchConfig $config=null, CirrusDebugOptions $debugOptions=null, NamespacePrefixParser $namespacePrefixParser=null, InterwikiResolver $interwikiResolver=null, TitleHelper $titleHelper=null) | |
setConnection (Connection $connection) | |
getConnection () | |
getConfig () | |
Get search config. | |
supports ( $feature) | |
Override supports to shut off updates to Cirrus via the SearchEngine infrastructure. | |
getValidSorts () | |
Get the sort of sorts we allow. | |
getLastSearchMetrics () | |
Get the metrics for the last search we performed. | |
completionSearchWithVariants ( $search) | |
Override variants function because we always do variants in the backend. | |
getProfiles ( $profileType, User $user=null) | |
extractProfileFromFeatureData ( $profileType) | |
(public for testing purposes) | |
makeSearchFieldMapping ( $name, $type) | |
Create a search field definition. | |
searchArchiveTitle ( $term) | |
Perform a title search in the article archive. | |
updateWeightedTags (ProperPageIdentity $page, string $tagPrefix, $tagNames=null, $tagWeights=null) | |
Request the setting of the weighted_tags field for the given tag(s) and weight(s). | |
resetWeightedTags (ProperPageIdentity $page, string $tagPrefix) | |
Request the reset of the weighted_tags field for the category $tagCategory. | |
countContentWords () | |
Public Attributes | |
const | AUTOSELECT_PROFILE = 'engine_autoselect' |
Special profile to instruct this class to use profile selection mechanism. | |
const | COMPLETION_PREFIX_FALLBACK_PROFILE = 'classic' |
@const string name of the prefixsearch fallback profile | |
const | MAX_TITLE_SEARCH = 255 |
@const int Maximum title length that we'll check in prefix and keyword searches. | |
const | EXTRA_FIELDS_TO_EXTRACT = 'extra-fields-to-extract' |
Name of the feature to extract more fields during a fulltext search request. | |
Protected Member Functions | |
doSearchText ( $term) | |
Overridden to delegate prefix searching to Searcher. | |
searchTextReal (SearchQuery $query) | |
Do the hard part of the searching - actual Searcher invocation. | |
getSuggestions ( $search, $variants, SearchConfig $config) | |
Look for suggestions using ES completion suggester. | |
completionSearchBackend ( $search) | |
Perform a completion search. | |
prefixSearch ( $search, $variants) | |
Older prefix search. | |
getUpdater () | |
Helper method to facilitate mocking during tests. | |
SearchEngine implementation for CirrusSearch.
Delegates to CirrusSearchSearcher for searches and CirrusSearchUpdater for updates. Note that lots of search behavior is hooked in CirrusSearchHooks rather than overridden here.
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
CirrusSearch\CirrusSearch::__construct | ( | SearchConfig | $config = null, |
CirrusDebugOptions | $debugOptions = null, | ||
NamespacePrefixParser | $namespacePrefixParser = null, | ||
InterwikiResolver | $interwikiResolver = null, | ||
TitleHelper | $titleHelper = null ) |
SearchConfig | null | $config | |
CirrusDebugOptions | null | $debugOptions | |
NamespacePrefixParser | null | $namespacePrefixParser | |
InterwikiResolver | null | $interwikiResolver | |
TitleHelper | null | $titleHelper |
|
protected |
Perform a completion search.
Does not resolve namespaces and does not check variants. We use parent search for:
string | $search |
CirrusSearch\CirrusSearch::completionSearchWithVariants | ( | $search | ) |
Override variants function because we always do variants in the backend.
string | $search |
CirrusSearch\CirrusSearch::countContentWords | ( | ) |
|
protected |
Overridden to delegate prefix searching to Searcher.
string | $term | text to search |
CirrusSearch\CirrusSearch::extractProfileFromFeatureData | ( | $profileType | ) |
(public for testing purposes)
string | $profileType |
CirrusSearch\CirrusSearch::getConfig | ( | ) |
Get search config.
CirrusSearch\CirrusSearch::getConnection | ( | ) |
CirrusSearch\CirrusSearch::getLastSearchMetrics | ( | ) |
Get the metrics for the last search we performed.
Null if we haven't done any.
CirrusSearch\CirrusSearch::getProfiles | ( | $profileType, | |
User | $user = null ) |
string | $profileType | |
User | null | $user |
|
protected |
Look for suggestions using ES completion suggester.
string | $search | Search string |
string[] | null | $variants | Search term variants |
SearchConfig | $config | search configuration |
|
protected |
Helper method to facilitate mocking during tests.
CirrusSearch\CirrusSearch::getValidSorts | ( | ) |
Get the sort of sorts we allow.
CirrusSearch\CirrusSearch::makeSearchFieldMapping | ( | $name, | |
$type ) |
Create a search field definition.
string | $name | |
string | $type |
|
protected |
Older prefix search.
string | $search | search text |
string[] | $variants |
CirrusSearch\CirrusSearch::resetWeightedTags | ( | ProperPageIdentity | $page, |
string | $tagPrefix ) |
Request the reset of the weighted_tags field for the category $tagCategory.
ProperPageIdentity | $page | |
string | $tagPrefix |
CirrusSearch\CirrusSearch::searchArchiveTitle | ( | $term | ) |
Perform a title search in the article archive.
string | $term | Raw search term |
|
protected |
Do the hard part of the searching - actual Searcher invocation.
SearchQuery | $query |
CirrusSearch\CirrusSearch::supports | ( | $feature | ) |
Override supports to shut off updates to Cirrus via the SearchEngine infrastructure.
Page updates and additions are chained on the end of the links update job. Deletes are noticed via the ArticleDeleteComplete hook.
string | $feature | feature name |
CirrusSearch\CirrusSearch::updateWeightedTags | ( | ProperPageIdentity | $page, |
string | $tagPrefix, | ||
$tagNames = null, | |||
$tagWeights = null ) |
Request the setting of the weighted_tags field for the given tag(s) and weight(s).
Will set a "$tagPrefix/$tagName" tag for each element of $tagNames, and will unset all other tags with the same prefix (in other words, this will replace the existing tag set for a given prefix). When $tagName is omitted, 'exists' will be used - this is canonical for tag types where the tag is fully determined by the prefix.
This is meant for testing and non-production setups. For production a more efficient batched update process can be implemented outside MediaWiki.
ProperPageIdentity | $page | |
string | $tagPrefix | |
string | string[] | null | $tagNames | |
int | int[] | null | $tagWeights | Tag weights (between 1-1000). When $tagNames is omitted, $tagWeights should be a single number; otherwise it should be a tagname => weight map. |
const CirrusSearch\CirrusSearch::AUTOSELECT_PROFILE = 'engine_autoselect' |
Special profile to instruct this class to use profile selection mechanism.
This allows to defer profile selection to when we actually perform the search. The reason is that the list of possible profiles is returned by self::getProfiles so instead of assigning a default profile at this point we use this special profile.
const CirrusSearch\CirrusSearch::EXTRA_FIELDS_TO_EXTRACT = 'extra-fields-to-extract' |
Name of the feature to extract more fields during a fulltext search request.
Expected value is a list of strings identifying the fields to extract out of the source document.
const CirrusSearch\CirrusSearch::MAX_TITLE_SEARCH = 255 |
@const int Maximum title length that we'll check in prefix and keyword searches.
Since titles can be 255 bytes in length we're setting this to 255 characters.