Class Connection
Constants
Property Summary
-
$_client protected
ElasticaClientElastica client instance
-
$_esLogger protected
ElasticLoggerInstance of ElasticLogger
-
$_logger protected
QueryLogger|LoggerInterfaceLogger object instance.
-
$cacher protected
CacheInterface -
$configName protected
stringThe connection name in the connection manager.
-
$logQueries protected
boolWhether or not query logging is enabled.
Method Summary
-
__call() public
Pass remaining methods to the elastica client (if they exist) And set the current logger based on current logQueries value
-
__construct() public
Constructor.
-
config() public
Get the config data for this connection.
-
configName() public
Get the configuration name for this connection.
-
disableConstraints() public
{@inheritDoc}
-
disableQueryLogging() public
Disable query logging
-
enableQueryLogging() public
Enable/disable query logging
-
getCacher() public
Get a cacher.
-
getDriver() public
Gets the driver instance.
-
getEsLogger() public
Return instance of ElasticLogger
-
getIndex() public
Returns the index for the given connection
-
getLogger() public
Get the logger object Will set the default logger to elasticsearch if found, or debug If none of the above are found the default Es logger will be used.
-
getSchemaCollection() public
Returns a SchemaCollection stub until we can add more abstract API's in Connection.
-
isQueryLoggingEnabled() public
Check if query logging is enabled.
-
setCacher() public
Set a cacher.
-
setLogger() public
Sets a logger
Method Detail
__call() ¶ public
__call(string $name, array $attributes): mixed
Pass remaining methods to the elastica client (if they exist) And set the current logger based on current logQueries value
Parameters
-
string$name Method name
-
array$attributes Method attributes
Returns
mixed__construct() ¶ public
__construct(array $config = [], callable|null $callback = null)
Constructor.
Parameters
-
array$config optional config options
-
callable|null$callback optional Callback function which can be used to be notified about errors (for example connection down)
configName() ¶ public
configName(): string
Get the configuration name for this connection.
Returns
stringdisableConstraints() ¶ public
disableConstraints(callable $operation): mixed
{@inheritDoc}
Elasticsearch does not deal with the concept of foreign key constraints This method just triggers the $callback argument.
Parameters
-
callable$operation The callback to execute within a transaction.
Returns
mixedThe return value of the callback.
Throws
ExceptionWill re-throw any exception raised in $callback after rolling back the transaction.
enableQueryLogging() ¶ public
enableQueryLogging(bool $value = true): $this
Enable/disable query logging
Parameters
-
bool$value optional Enable/disable query logging
Returns
$thisgetCacher() ¶ public
getCacher(): Psr\SimpleCache\CacheInterface
Get a cacher.
Returns
Psr\SimpleCache\CacheInterfacegetDriver() ¶ public
getDriver(string $role = self::ROLE_WRITE): Elastica\Client
Gets the driver instance.
Parameters
-
string$role optional
Returns
Elastica\ClientSee Also
getEsLogger() ¶ public
getEsLogger(): Cake\ElasticSearch\Datasource\Log\ElasticLogger
Return instance of ElasticLogger
Returns
Cake\ElasticSearch\Datasource\Log\ElasticLoggergetIndex() ¶ public
getIndex(string|null $name = null): Elastica\Index
Returns the index for the given connection
Parameters
-
string|null$name optional Index name to create connection to, if no value is passed it will use the default index name for the connection.
Returns
Elastica\IndexIndex for the given name
getLogger() ¶ public
getLogger(): Psr\Log\LoggerInterface
Get the logger object Will set the default logger to elasticsearch if found, or debug If none of the above are found the default Es logger will be used.
Returns
Psr\Log\LoggerInterfacelogger instance
getSchemaCollection() ¶ public
getSchemaCollection(): Cake\ElasticSearch\Datasource\SchemaCollection
Returns a SchemaCollection stub until we can add more abstract API's in Connection.
Returns
Cake\ElasticSearch\Datasource\SchemaCollectionisQueryLoggingEnabled() ¶ public
isQueryLoggingEnabled(): bool
Check if query logging is enabled.
Returns
boolsetCacher() ¶ public
setCacher(Psr\SimpleCache\CacheInterface $cacher): $this
Set a cacher.
Parameters
-
Psr\SimpleCache\CacheInterface$cacher
Returns
$thissetLogger() ¶ public
setLogger(Cake\Database\Log\QueryLogger|Psr\Log\LoggerInterface $logger): $this
Sets a logger
Parameters
-
Cake\Database\Log\QueryLogger|Psr\Log\LoggerInterface$logger Logger instance
Returns
$this