CirrusSearch
Elasticsearch-powered search for MediaWiki
Loading...
Searching...
No Matches
CirrusSearch\DataSender Class Reference

Handles non-maintenance write operations to the elastic search cluster. More...

+ Inheritance diagram for CirrusSearch\DataSender:
+ Collaboration diagram for CirrusSearch\DataSender:

Public Member Functions

 __construct (Connection $conn, SearchConfig $config, StatsdDataFactoryInterface $stats=null, DocumentSizeLimiter $docSizeLimiter=null)
 
 sendUpdateWeightedTags (string $indexSuffix, array $docIds, string $tagField, string $tagPrefix, $tagNames=null, array $tagWeights=null, int $batchSize=30)
 
 sendResetWeightedTags (string $indexSuffix, array $docIds, string $tagField, string $tagPrefix, int $batchSize=30)
 
 sendData ( $indexSuffix, array $documents)
 
 sendDeletes ( $docIds, $indexSuffix=null)
 Send delete requests to Elasticsearch.
 
 sendOtherIndexUpdates ( $localSite, $indexName, array $otherActions, $batchSize=30)
 
 docToSuperDetectNoopScript (\Elastica\Document $doc)
 Converts a document into a call to super_detect_noop from the wikimedia-extra plugin.
 
- 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

 decideRequiredSetAction (Title $title)
 Decide what action is required to the other index to make it up to data with the current wiki state.
 
 bulkResponseExceptionIsJustDocumentMissing (ResponseException $exception, $logCallback=null)
 Check if $exception is a bulk response exception that just contains document is missing failures.
 
 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)
 

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
 
- Protected Attributes inherited from CirrusSearch\ElasticsearchIntermediary
 $connection
 
 $user
 
 $currentRequestLog = null
 
- Static Protected Attributes inherited from CirrusSearch\ElasticsearchIntermediary
static $requestLogger
 

Detailed Description

Handles non-maintenance write operations to the elastic search cluster.

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

Constructor & Destructor Documentation

◆ __construct()

CirrusSearch\DataSender::__construct ( Connection $conn,
SearchConfig $config,
StatsdDataFactoryInterface $stats = null,
DocumentSizeLimiter $docSizeLimiter = null )
Parameters
Connection$conn
SearchConfig$config
StatsdDataFactoryInterface | null$stats
DocumentSizeLimiter | null$docSizeLimiter

Member Function Documentation

◆ bulkResponseExceptionIsJustDocumentMissing()

CirrusSearch\DataSender::bulkResponseExceptionIsJustDocumentMissing ( ResponseException $exception,
$logCallback = null )
protected

Check if $exception is a bulk response exception that just contains document is missing failures.

Parameters
ResponseException$exceptionexception to check
callable | null$logCallbackCallback in which to do some logging. Callback will be passed the id of the missing document.
Returns
bool

◆ decideRequiredSetAction()

CirrusSearch\DataSender::decideRequiredSetAction ( Title $title)
protected

Decide what action is required to the other index to make it up to data with the current wiki state.

This will always check against the master database.

Parameters
Title$titleThe title to decide the action for
Returns
string The set action to be performed. Either 'add' or 'remove'

◆ newLog()

CirrusSearch\DataSender::newLog ( $description,
$queryType,
array $extra = [] )
protected
Parameters
string$description
string$queryType
string[]$extra
Returns
SearchRequestLog

Reimplemented from CirrusSearch\ElasticsearchIntermediary.

◆ sendData()

CirrusSearch\DataSender::sendData ( $indexSuffix,
array $documents )
Parameters
string$indexSuffixsuffix of index to which to send $documents
\Elastica\Document[]$documentsdocuments to send
Returns
Status

Transform the finalized documents into noop scripts if possible to reduce update load.

◆ sendDeletes()

CirrusSearch\DataSender::sendDeletes ( $docIds,
$indexSuffix = null )

Send delete requests to Elasticsearch.

Parameters
string[]$docIdselasticsearch document ids to delete
string | null$indexSuffixindex from which to delete. null means all.
Returns
Status

◆ sendOtherIndexUpdates()

CirrusSearch\DataSender::sendOtherIndexUpdates ( $localSite,
$indexName,
array $otherActions,
$batchSize = 30 )
Parameters
string$localSiteThe wikiId to add/remove from local_sites_with_dupe
string$indexNameThe name of the index to perform updates to
array[]$otherActionsA list of arrays each containing the id within elasticsearch ('docId') and the article namespace ('ns') and DB key ('dbKey') at the within $localSite
int$batchSizenumber of docs to update in a single bulk
Returns
Status

◆ sendResetWeightedTags()

CirrusSearch\DataSender::sendResetWeightedTags ( string $indexSuffix,
array $docIds,
string $tagField,
string $tagPrefix,
int $batchSize = 30 )
Parameters
string$indexSuffix
string[]$docIds
string$tagField
string$tagPrefix
int$batchSize
Returns
Status

◆ sendUpdateWeightedTags()

CirrusSearch\DataSender::sendUpdateWeightedTags ( string $indexSuffix,
array $docIds,
string $tagField,
string $tagPrefix,
$tagNames = null,
array $tagWeights = null,
int $batchSize = 30 )
Parameters
string$indexSuffix
string[]$docIds
string$tagField
string$tagPrefix
string | string[] | null$tagNamesA tag name or list of tag names. Each tag will be set for each document ID. Omit for tags which are fully defined by their prefix.
int[] | int[][] | null$tagWeightsAn optional map of docid => weight. When $tagName is null, the weight is an integer. When $tagName is not null, the weight is itself a tagname => int map. Weights are between 1-1000, and can be omitted (in which case no update will be sent for the corresponding docid/tag combination).
int$batchSize
Returns
Status

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