TTMServer backed based on ElasticSearch. More...
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 ( $sourceLanguage, $targetLanguage, $text) | |
Fetches all relevant suggestions for given text. | |
update (MessageHandle $handle, $targetText) | |
Add / update translations. | |
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 before every batch (MessageGroup). | |
endBootstrap () | |
Do any cleanup, optimizing etc. | |
getClient () | |
useWikimediaExtraPlugin () | |
getIndex () | |
setLogger ( $logger) | |
setDoReIndex () | |
Force the update of index mappings @inheritDoc. | |
createSearch ( $queryString, $opts, $highlight) | |
Search interface. | |
search ( $queryString, $opts, $highlight) | |
Search interface. | |
getFacets ( $resultset) | |
getTotalHits ( $resultset) | |
getDocuments ( $resultset) | |
Public Member Functions inherited from TTMServer | |
__construct (array $config) | |
getMirrors () | |
isFrozen () | |
Public Member Functions inherited from WritableTTMServer | |
getMirrors () | |
Get the list of services to duplicate writes to make them "mirrors" of this service. | |
isFrozen () | |
Check if the service is frozen, attempting to write to a frozen service may lead to errors or unexpected behaviors. | |
Protected Member Functions | |
doQuery ( $sourceLanguage, $targetLanguage, $text) | |
createDocument (MessageHandle $handle, $text, $revId) | |
getShardCount () | |
getReplicaCount () | |
getIndexHealth ( $indexName) | |
Get index health TODO: Remove this code in the future as we drop support for older versions of the Elastica extension. | |
waitForGreen ( $indexName, $timeout) | |
Wait for the index to go green. | |
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 | factory (array $config) |
static | primary () |
Returns the primary server instance, useful for chaining. | |
static | sortSuggestions (array $suggestions) |
static | levenshtein ( $str1, $str2, $length1, $length2) |
PHP implementation of Levenshtein edit distance algorithm. | |
static | onDelete (WikiPage $wikipage) |
Hook: ArticleDeleteComplete. | |
static | onChange (MessageHandle $handle) |
Called from TranslateEditAddons::onSave. | |
static | onGroupChange (MessageHandle $handle, $old) |
TTMServer backed based on ElasticSearch.
Depends on Elastica.
Definition at line 29 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::batchInsertDefinitions | ( | array | $batch | ) |
array[] | $batch | @phan-param array<int,array{0:MessageHandle,1:string,2:string}> $batch |
Implements WritableTTMServer.
Definition at line 433 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::batchInsertTranslations | ( | array | $batch | ) |
Called multiple times per batch if necessary.
array | $batch |
Implements WritableTTMServer.
Definition at line 443 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::beginBatch | ( | ) |
Called before every batch (MessageGroup).
Implements WritableTTMServer.
Definition at line 425 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::beginBootstrap | ( | ) |
Begin the bootstrap process.
RuntimeException |
Implements WritableTTMServer.
Definition at line 363 of file ElasticSearchTTMServer.php.
|
protected |
MessageHandle | $handle | |
string | $text | |
int | $revId |
Definition at line 298 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::createIndex | ( | $rebuild | ) |
Create index.
bool | $rebuild | Deletes index first if already exists |
Definition at line 321 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::createSearch | ( | $queryString, | |
$opts, | |||
$highlight ) |
Search interface.
string | $queryString | |
array | $opts | |
array | $highlight |
Definition at line 673 of file ElasticSearchTTMServer.php.
|
protected |
Definition at line 74 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::endBatch | ( | ) |
Called before every batch (MessageGroup).
Implements WritableTTMServer.
Definition at line 465 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::endBootstrap | ( | ) |
Do any cleanup, optimizing etc.
Implements WritableTTMServer.
Definition at line 469 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::expandLocation | ( | array | $suggestion | ) |
Given suggestion returned by this TTMServer, constructs fully qualified URL to the location of the translation.
array | $suggestion |
Implements ReadableTTMServer.
Definition at line 62 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::getClient | ( | ) |
Definition at line 476 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::getDocuments | ( | $resultset | ) |
\Elastica\ResultSet | $resultset |
Implements SearchableTTMServer.
Definition at line 785 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::getFacets | ( | $resultset | ) |
\Elastica\ResultSet | $resultset |
Implements SearchableTTMServer.
Definition at line 755 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::getIndex | ( | ) |
Definition at line 497 of file ElasticSearchTTMServer.php.
|
protected |
Get index health TODO: Remove this code in the future as we drop support for older versions of the Elastica extension.
string | $indexName |
Definition at line 518 of file ElasticSearchTTMServer.php.
|
protected |
Definition at line 506 of file ElasticSearchTTMServer.php.
|
protected |
Definition at line 502 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::getTotalHits | ( | $resultset | ) |
\Elastica\ResultSet | $resultset |
Implements SearchableTTMServer.
Definition at line 777 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::isLocalSuggestion | ( | array | $suggestion | ) |
Determines if the suggestion returned by this TTMServer comes from this wiki or any other wiki.
array | $suggestion |
Implements ReadableTTMServer.
Definition at line 58 of file ElasticSearchTTMServer.php.
|
protected |
Definition at line 581 of file ElasticSearchTTMServer.php.
|
protected |
Parse query string and build the search query.
string | $queryString | |
array | $opts |
Definition at line 601 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::query | ( | $sourceLanguage, | |
$targetLanguage, | |||
$text ) |
Fetches all relevant suggestions for given text.
string | $sourceLanguage | language code for the provide text |
string | $targetLanguage | language code for the suggestions |
string | $text | the text for which to search suggestions |
Implements ReadableTTMServer.
Definition at line 66 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::search | ( | $queryString, | |
$opts, | |||
$highlight ) |
Search interface.
string | $queryString | |
array | $opts | |
array | $highlight |
TTMServerException |
Implements SearchableTTMServer.
Definition at line 741 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::setDoReIndex | ( | ) |
Force the update of index mappings @inheritDoc.
Implements WritableTTMServer.
Definition at line 591 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::setLogger | ( | $logger | ) |
Definition at line 576 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::update | ( | MessageHandle | $handle, |
$targetText ) |
Add / update translations.
MessageHandle | $handle | |
?string | $targetText |
RuntimeException |
Implements WritableTTMServer.
Definition at line 235 of file ElasticSearchTTMServer.php.
ElasticSearchTTMServer::useWikimediaExtraPlugin | ( | ) |
Definition at line 488 of file ElasticSearchTTMServer.php.
|
protected |
Wait for the index to go green.
NOTE: This method has been copied and adjusted from CirrusSearch/includes/Maintenance/ConfigUtils.php. Ideally we'd like to make these utility methods available in the Elastica extension, but this one requires some refactoring in cirrus first. TODO: Remove this code in the future as we drop support for older versions of the Elastica extension.
string | $indexName | |
int | $timeout |
Definition at line 541 of file ElasticSearchTTMServer.php.
|
protected |
Definition at line 560 of file ElasticSearchTTMServer.php.
|
protected |
Definition at line 48 of file ElasticSearchTTMServer.php.
|
protected |
Reference to the maintenance script to relay logging output.
Definition at line 52 of file ElasticSearchTTMServer.php.
|
protected |
Used for Reindex.
Definition at line 56 of file ElasticSearchTTMServer.php.