CirrusSearch
Elasticsearch-powered search for MediaWiki
|
Base class with useful functions for communicating with Elasticsearch. More...
Public Member Functions | |
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. | |
Static Public Member Functions | |
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 | |
Protected Member Functions | |
__construct (Connection $connection, ?UserIdentity $user=null, $slowSeconds=null, $extraBackendLatency=0) | |
startNewLog ( $description, $queryType, array $extra=[]) | |
newLog ( $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 | |
$connection | |
$user | |
$currentRequestLog = null | |
Static Protected Attributes | |
static | $requestLogger |
Base class with useful functions for communicating with Elasticsearch.
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
|
protected |
Connection | $connection | |
UserIdentity | null | $user | user for which this search is being performed. Attached to slow request logs. Note that null isn't for anonymous users
|
float | null | $slowSeconds | how many seconds a request through this intermediary needs to take before it counts as slow. 0 means none count as slow. Defaults to CirrusSearchSlowSearch config option. |
int | $extraBackendLatency | artificial backend latency. |
|
static |
string | $key | |
string | $value |
|
protected |
SearchMetricsProvider | $provider |
CirrusSearch\ElasticsearchIntermediary::failure | ( | ?ExceptionInterface | $exception = null, |
?Connection | $connection = null ) |
Log a failure and return an appropriate status.
Public so it can be called from pool counter methods.
ExceptionInterface | null | $exception | if the request failed |
Connection | null | $connection | The connection that the failed request was performed against. Will use $this->connection when not provided. |
|
protected |
string | $searchType |
|
static |
Report the types of queries that were issued within the current request.
CirrusSearch\ElasticsearchIntermediary::getSearchMetrics | ( | ) |
Get the search metrics we have.
|
protected |
string | $searchType |
|
static |
|
static |
check validity of the multisearch response
MultiResultSet | $multiResultSet |
|
abstractprotected |
string | $description | A psr-3 compliant string describing the request |
string | $queryType | The type of search being performed such as fulltext, get, etc. |
array | $extra | A map of additional request-specific data |
Reimplemented in CirrusSearch\BuildDocument\RedirectsAndIncomingLinks, CirrusSearch\CompletionSuggester, CirrusSearch\DataSender, CirrusSearch\Searcher, CirrusSearch\Updater, and CirrusSearch\Version.
|
protected |
Search | $search | |
RequestLog | $log | |
Connection | null | $connection | |
callable | null | $resultsTransformer | that accepts a Multi/ResultSets |
|
static |
This is set externally because we don't have complete control, from the SearchEngine interface, of what is actually sent to the user.
Instead hooks receive the final results that will be sent to the user and set them here.
Accepts two result sets because some places (Special:Search) perform multiple searches. This can be called multiple times, but only that last call wins. For API's that is correct, for Special:Search a hook catches the final results and sets them here.
ISearchResultSet[] | $matches |
CirrusSearch\ElasticsearchIntermediary::start | ( | RequestLog | $log | ) |
Mark the start of a request to Elasticsearch.
Public so it can be called from pool counter methods.
RequestLog | $log |
|
protected |
string | $description | A psr-3 compliant string describing the request |
string | $queryType | The type of search being performed such as fulltext, get, etc. |
array | $extra | A map of additional request-specific data |
CirrusSearch\ElasticsearchIntermediary::success | ( | $result = null, | |
?Connection | $connection = null ) |
Log a successful request and return the provided result in a good Status.
If you don't need the status just ignore the return. Public so it can be called from pool counter methods.
mixed | null | $result | result of the request. defaults to null in case the request doesn't have a result |
Connection | null | $connection | The connection the succesful request was performed against. Will use $this->connection when not provided. |
CirrusSearch\ElasticsearchIntermediary::successViaCache | ( | RequestLog | $log | ) |
Log a successful request when the response comes from a cache outside elasticsearch.
This is a combination of self::start() and self::success().
RequestLog | $log |