CirrusSearch
Elasticsearch-powered search for MediaWiki
|
Performs searches using Elasticsearch. More...
Public Member Functions | |
__construct (Connection $conn, $offset, $limit, SearchConfig $config, array $namespaces=null, User $user=null, $index=false, CirrusDebugOptions $options=null, NamespacePrefixParser $namespacePrefixParser=null, InterwikiResolver $interwikiResolver=null, TitleHelper $titleHelper=null, CirrusSearchHookRunner $cirrusSearchHookRunner=null) | |
search (SearchQuery $query) | |
Unified search public entry-point. | |
setResultsType ( $resultsType) | |
isReturnRaw () | |
Is this searcher used to return debugging info? | |
setSort ( $sort) | |
Set the type of sort to perform. | |
limitSearchToLocalWiki ( $limitSearchToLocalWiki) | |
Should this search limit results to the local wiki? If not called the default is false. | |
nearMatchTitleSearch ( $term) | |
Perform a "near match" title search which is pretty much a prefix match without the prefixes. | |
countContentWords () | |
Perform a sum over the number of words in the content index. | |
prefixSearch ( $term, $variants=[]) | |
Perform a prefix search. | |
get (array $docIds, $sourceFiltering, $usePoolCounter=true) | |
Get the page with $docId. | |
updateNamespacesFromQuery (&$query) | |
Attempt to suck a leading namespace followed by a colon from the query string. | |
getSearchContext () | |
processRawReturn ( $result, WebRequest $request) | |
If we're supposed to create raw result, create and return it, or output it and finish. | |
searchArchive ( $term) | |
Search titles in archive. | |
applyDebugOptionsToQuery (Query $query) | |
Apply debug options to the elastica query. | |
makeSearcher (SearchQuery $query) | |
getOffsetLimit () | |
Visible for testing. | |
Public Member Functions inherited from CirrusSearch\ElasticsearchIntermediary | |
start (RequestLog $log) | |
Mark the start of a request to Elasticsearch. | |
success ( $result=null, Connection $connection=null) | |
Log a successful request and return the provided result in a good Status. | |
successViaCache (RequestLog $log) | |
Log a successful request when the response comes from a cache outside elasticsearch. | |
failure (ExceptionInterface $exception=null, Connection $connection=null) | |
Log a failure and return an appropriate status. | |
getSearchMetrics () | |
Get the search metrics we have. | |
Protected Member Functions | |
buildFullTextSearch ( $term) | |
Build full text search for articles with provided term. | |
buildSearch () | |
searchOne () | |
Perform a single-query search. | |
getQueryCacheStatsKey () | |
newLog ( $description, $queryType, array $extra=[]) | |
Protected Member Functions inherited from CirrusSearch\ElasticsearchIntermediary | |
__construct (Connection $connection, UserIdentity $user=null, $slowSeconds=null, $extraBackendLatency=0) | |
startNewLog ( $description, $queryType, array $extra=[]) | |
getTimeout ( $searchType='default') | |
getClientTimeout ( $searchType='default') | |
appendMetrics (SearchMetricsProvider $provider) | |
runMSearch (Search $search, RequestLog $log, Connection $connection=null, callable $resultsTransformer=null) | |
Protected Attributes | |
$offset | |
$limit | |
$indexBaseName | |
$config | |
$searchContext | |
$interwikiResolver | |
$titleHelper | |
$cirrusSearchHookRunner | |
Protected Attributes inherited from CirrusSearch\ElasticsearchIntermediary | |
$connection | |
$user | |
$currentRequestLog = null | |
Additional Inherited Members | |
Static Public Member Functions inherited from CirrusSearch\ElasticsearchIntermediary | |
static | setResultPages (array $matches) |
This is set externally because we don't have complete control, from the SearchEngine interface, of what is actually sent to the user. | |
static | getQueryTypesUsed () |
Report the types of queries that were issued within the current request. | |
static | hasQueryLogs () |
static | appendLastLogPayload ( $key, $value) |
static | isMSearchResultSetOK (MultiResultSet $multiResultSet) |
check validity of the multisearch response | |
Static Protected Attributes inherited from CirrusSearch\ElasticsearchIntermediary | |
static | $requestLogger |
Performs searches using Elasticsearch.
Note that each instance of this class is single use only.
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\Searcher::__construct | ( | Connection | $conn, |
$offset, | |||
$limit, | |||
SearchConfig | $config, | ||
array | $namespaces = null, | ||
User | $user = null, | ||
$index = false, | |||
CirrusDebugOptions | $options = null, | ||
NamespacePrefixParser | $namespacePrefixParser = null, | ||
InterwikiResolver | $interwikiResolver = null, | ||
TitleHelper | $titleHelper = null, | ||
CirrusSearchHookRunner | $cirrusSearchHookRunner = null ) |
Connection | $conn | |
int | $offset | Offset the results by this much |
int | $limit | Limit the results to this many |
SearchConfig | $config | Configuration settings |
int[] | null | $namespaces | Array of namespace numbers to search or null to search all namespaces. |
User | null | $user | user for which this search is being performed. Attached to slow request logs. |
string | bool | $index | Base name for index to search from, defaults to $wgCirrusSearchIndexBaseName |
CirrusDebugOptions | null | $options | the debugging options to use or null to use defaults |
NamespacePrefixParser | null | $namespacePrefixParser | |
InterwikiResolver | null | $interwikiResolver | |
TitleHelper | null | $titleHelper | |
CirrusSearchHookRunner | null | $cirrusSearchHookRunner |
CirrusSearch\Searcher::applyDebugOptionsToQuery | ( | Query | $query | ) |
Apply debug options to the elastica query.
Query | $query |
|
protected |
Build full text search for articles with provided term.
All the state is applied to $this->searchContext. The returned query builder can be used to build a degraded query if necessary.
string | $term | term to search |
|
protected |
CirrusSearch\Searcher::countContentWords | ( | ) |
Perform a sum over the number of words in the content index.
CirrusSearch\Searcher::get | ( | array | $docIds, |
$sourceFiltering, | |||
$usePoolCounter = true ) |
Get the page with $docId.
Note that the result is a status containing all pages found. It is possible to find more then one page if the page is in multiple indexes.
string[] | $docIds | array of document ids |
string[] | bool | $sourceFiltering | source filtering to apply |
bool | $usePoolCounter | false to disable the pool counter |
CirrusSearch\Searcher::getOffsetLimit | ( | ) |
Visible for testing.
|
protected |
Reimplemented in CirrusSearch\InterwikiSearcher.
CirrusSearch\Searcher::getSearchContext | ( | ) |
CirrusSearch\Searcher::isReturnRaw | ( | ) |
Is this searcher used to return debugging info?
CirrusSearch\Searcher::limitSearchToLocalWiki | ( | $limitSearchToLocalWiki | ) |
Should this search limit results to the local wiki? If not called the default is false.
bool | $limitSearchToLocalWiki | should the results be limited? |
CirrusSearch\Searcher::makeSearcher | ( | SearchQuery | $query | ) |
CirrusSearch\Searcher::nearMatchTitleSearch | ( | $term | ) |
Perform a "near match" title search which is pretty much a prefix match without the prefixes.
string | $term | text by which to search |
|
protected |
string | $description | |
string | $queryType | |
string[] | $extra |
Reimplemented from CirrusSearch\ElasticsearchIntermediary.
CirrusSearch\Searcher::prefixSearch | ( | $term, | |
$variants = [] ) |
Perform a prefix search.
string | $term | text by which to search |
string[] | $variants | variants to search for |
CirrusSearch\Searcher::processRawReturn | ( | $result, | |
WebRequest | $request ) |
If we're supposed to create raw result, create and return it, or output it and finish.
mixed | $result | Search result data |
WebRequest | $request | Request context |
CirrusSearch\Searcher::search | ( | SearchQuery | $query | ) |
Unified search public entry-point.
NOTE: only fulltext search supported for now.
SearchQuery | $query |
CirrusSearch\Searcher::searchArchive | ( | $term | ) |
Search titles in archive.
string | $term |
|
protected |
Perform a single-query search.
CirrusSearch\Searcher::setResultsType | ( | $resultsType | ) |
ResultsType | $resultsType | results type to return |
CirrusSearch\Searcher::setSort | ( | $sort | ) |
Set the type of sort to perform.
Must be 'relevance', 'title_asc', 'title_desc'.
string | $sort | sort type |
CirrusSearch\Searcher::updateNamespacesFromQuery | ( | & | $query | ) |
Attempt to suck a leading namespace followed by a colon from the query string.
Reaches out to Elasticsearch to perform normalized lookup against the namespaces. Should be fast but for the network hop.
string | &$query |