Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
ElasticSearchTTMServer Class Reference

TTMServer backed based on ElasticSearch. More...

Inheritance diagram for ElasticSearchTTMServer:
TTMServer MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer MediaWiki\Extension\Translate\TtmServer\WritableTtmServer MediaWiki\Extension\Translate\TtmServer\SearchableTtmServer

Public Member Functions

 isLocalSuggestion (array $suggestion)
 Determines if the suggestion returned by this TTMServer comes from this wiki or any other wiki.
 
 expandLocation (array $suggestion)
 Given suggestion returned by this TTMServer, constructs fully qualified URL to the location of the translation.
 
 query (string $sourceLanguage, string $targetLanguage, string $text)
 Fetches all relevant suggestions for given text.
 
 update (MessageHandle $handle, ?string $targetText)
 Shovels the new translation into translation memory.
 
 createIndex ( $rebuild)
 Create index.
 
 beginBootstrap ()
 Begin the bootstrap process.
 
 beginBatch ()
 Called before every batch (MessageGroup).
 
 batchInsertDefinitions (array $batch)
 
 batchInsertTranslations (array $batch)
 Called multiple times per batch if necessary.
 
 endBatch ()
 Called after every batch (MessageGroup).
 
 endBootstrap ()
 Do any cleanup, optimizing etc.
 
 getClient ()
 
 useWikimediaExtraPlugin ()
 
 getIndex ()
 
 setLogger ( $logger)
 
 setDoReIndex ()
 Instruct the service to fully wipe the index and start from scratch.
 
 createSearch ( $queryString, $opts, $highlight)
 Search interface.
 
 search ( $queryString, $opts, $highlight)
 Search interface.
 
 getFacets ( $resultset)
 @inheritDoc
 
 getTotalHits ( $resultset)
 @inheritDoc
 
 getDocuments ( $resultset)
 @inheritDoc
 
- Public Member Functions inherited from TTMServer
 __construct (array $config)
 
- Public Member Functions inherited from MediaWiki\Extension\Translate\TtmServer\SearchableTtmServer
 search (string $queryString, array $opts, array $highlight)
 Performs a search in the translation database.
 

Protected Member Functions

 doQuery ( $sourceLanguage, $targetLanguage, $text)
 
 createDocument (MessageHandle $handle, $text, $revId)
 
 getShardCount ()
 
 getReplicaCount ()
 
 waitUntilReady ()
 
 logOutput ( $text)
 
 parseQueryString ( $queryString, array $opts)
 Parse query string and build the search query.
 

Protected Attributes

 $client
 
 $logger
 Reference to the maintenance script to relay logging output.
 
 $updateMapping = false
 Used for Reindex.
 
- Protected Attributes inherited from TTMServer
 $config
 

Additional Inherited Members

- Static Public Member Functions inherited from TTMServer
static sortSuggestions (array $suggestions)
 
static onDelete (WikiPage $wikipage)
 Hook: ArticleDeleteComplete.
 
static onChange (MessageHandle $handle)
 Called from TranslateEditAddons::onSave.
 
static onGroupChange (MessageHandle $handle, $old)
 

Detailed Description

TTMServer backed based on ElasticSearch.

Depends on Elastica.

Since
2014.04

Definition at line 38 of file ElasticSearchTTMServer.php.

Member Function Documentation

◆ batchInsertDefinitions()

ElasticSearchTTMServer::batchInsertDefinitions ( array $batch)
Parameters
array[]$batch@phan-param array<int,array{0:MessageHandle,1:string,2:string}> $batch

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 429 of file ElasticSearchTTMServer.php.

◆ batchInsertTranslations()

ElasticSearchTTMServer::batchInsertTranslations ( array $batch)

Called multiple times per batch if necessary.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 439 of file ElasticSearchTTMServer.php.

◆ beginBatch()

ElasticSearchTTMServer::beginBatch ( )

Called before every batch (MessageGroup).

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 422 of file ElasticSearchTTMServer.php.

◆ beginBootstrap()

ElasticSearchTTMServer::beginBootstrap ( )

Begin the bootstrap process.

Exceptions
RuntimeException

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 360 of file ElasticSearchTTMServer.php.

◆ createDocument()

ElasticSearchTTMServer::createDocument ( MessageHandle $handle,
$text,
$revId )
protected
Parameters
MessageHandle$handle
string$text
int$revId
Returns
Document

Definition at line 298 of file ElasticSearchTTMServer.php.

◆ createIndex()

ElasticSearchTTMServer::createIndex ( $rebuild)

Create index.

Parameters
bool$rebuildDeletes index first if already exists

Definition at line 321 of file ElasticSearchTTMServer.php.

◆ createSearch()

ElasticSearchTTMServer::createSearch ( $queryString,
$opts,
$highlight )

Search interface.

Parameters
string$queryString
array$opts
array$highlight
Returns
\Elastica\Search

Definition at line 612 of file ElasticSearchTTMServer.php.

◆ doQuery()

ElasticSearchTTMServer::doQuery ( $sourceLanguage,
$targetLanguage,
$text )
protected

Definition at line 83 of file ElasticSearchTTMServer.php.

◆ endBatch()

ElasticSearchTTMServer::endBatch ( )

Called after every batch (MessageGroup).

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 460 of file ElasticSearchTTMServer.php.

◆ endBootstrap()

ElasticSearchTTMServer::endBootstrap ( )

Do any cleanup, optimizing etc.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 463 of file ElasticSearchTTMServer.php.

◆ expandLocation()

ElasticSearchTTMServer::expandLocation ( array $suggestion)

Given suggestion returned by this TTMServer, constructs fully qualified URL to the location of the translation.

Returns
string URL

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 71 of file ElasticSearchTTMServer.php.

◆ getClient()

ElasticSearchTTMServer::getClient ( )

Definition at line 470 of file ElasticSearchTTMServer.php.

◆ getDocuments()

ElasticSearchTTMServer::getDocuments ( $resultset)

◆ getFacets()

ElasticSearchTTMServer::getFacets ( $resultset)

◆ getIndex()

ElasticSearchTTMServer::getIndex ( )

Definition at line 491 of file ElasticSearchTTMServer.php.

◆ getReplicaCount()

ElasticSearchTTMServer::getReplicaCount ( )
protected

Definition at line 500 of file ElasticSearchTTMServer.php.

◆ getShardCount()

ElasticSearchTTMServer::getShardCount ( )
protected

Definition at line 496 of file ElasticSearchTTMServer.php.

◆ getTotalHits()

ElasticSearchTTMServer::getTotalHits ( $resultset)

◆ isLocalSuggestion()

ElasticSearchTTMServer::isLocalSuggestion ( array $suggestion)

Determines if the suggestion returned by this TTMServer comes from this wiki or any other wiki.

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 67 of file ElasticSearchTTMServer.php.

◆ logOutput()

ElasticSearchTTMServer::logOutput ( $text)
protected

Definition at line 524 of file ElasticSearchTTMServer.php.

◆ parseQueryString()

ElasticSearchTTMServer::parseQueryString ( $queryString,
array $opts )
protected

Parse query string and build the search query.

Parameters
string$queryString
array$opts
Returns
array

Definition at line 540 of file ElasticSearchTTMServer.php.

◆ query()

ElasticSearchTTMServer::query ( string $sourceLanguage,
string $targetLanguage,
string $text )

Fetches all relevant suggestions for given text.

Parameters
string$sourceLanguagelanguage code for the provide text
string$targetLanguagelanguage code for the suggestions
string$textthe text for which to search suggestions
Returns
array List: unordered suggestions, which each has fields:
  • source: String: the original text of the suggestion
  • target: String: the suggestion
  • context: String: title of the page where the suggestion comes from
  • quality: Float: the quality of suggestion, 1 is perfect match

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 75 of file ElasticSearchTTMServer.php.

◆ search()

ElasticSearchTTMServer::search ( $queryString,
$opts,
$highlight )

Search interface.

Parameters
string$queryString
array$opts
array$highlight
Exceptions
TtmServerException
Returns
ResultSet

Definition at line 680 of file ElasticSearchTTMServer.php.

◆ setDoReIndex()

ElasticSearchTTMServer::setDoReIndex ( )

Instruct the service to fully wipe the index and start from scratch.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 530 of file ElasticSearchTTMServer.php.

◆ setLogger()

ElasticSearchTTMServer::setLogger ( $logger)

Definition at line 519 of file ElasticSearchTTMServer.php.

◆ update()

ElasticSearchTTMServer::update ( MessageHandle $handle,
?string $targetText )

Shovels the new translation into translation memory.

Use this for single updates (=after message edit). If no text is provided, entry will be removed from the translation memory.

Parameters
MessageHandle$handle
string | null$targetTextUse null to only delete.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 236 of file ElasticSearchTTMServer.php.

◆ useWikimediaExtraPlugin()

ElasticSearchTTMServer::useWikimediaExtraPlugin ( )
Returns
true if the backend is configured with the wikimedia extra plugin

Definition at line 482 of file ElasticSearchTTMServer.php.

◆ waitUntilReady()

ElasticSearchTTMServer::waitUntilReady ( )
protected

Definition at line 504 of file ElasticSearchTTMServer.php.

Member Data Documentation

◆ $client

ElasticSearchTTMServer::$client
protected

Definition at line 57 of file ElasticSearchTTMServer.php.

◆ $logger

ElasticSearchTTMServer::$logger
protected

Reference to the maintenance script to relay logging output.

Definition at line 61 of file ElasticSearchTTMServer.php.

◆ $updateMapping

ElasticSearchTTMServer::$updateMapping = false
protected

Used for Reindex.

Definition at line 65 of file ElasticSearchTTMServer.php.


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