Class Connection
Constants
Property Summary
-
$_client protected
ElasticaClient
Elastica client instance
-
$_esLogger protected
ElasticLogger
Instance of ElasticLogger
-
$_logger protected
QueryLogger|LoggerInterface
Logger object instance.
-
$cacher protected
CacheInterface
-
$configName protected
string
The connection name in the connection manager.
-
$logQueries protected
bool
Whether 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
string
disableConstraints() ¶ 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
mixed
Throws
Exception
Will 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
$this
getCacher() ¶ public
getCacher(): Psr\SimpleCache\CacheInterface
Get a cacher.
Returns
Psr\SimpleCache\CacheInterface
getDriver() ¶ public
getDriver(string $role = self::ROLE_WRITE): Elastica\Client
Gets the driver instance.
Parameters
-
string
$role optional
Returns
Elastica\Client
See Also
getEsLogger() ¶ public
getEsLogger(): Cake\ElasticSearch\Datasource\Log\ElasticLogger
Return instance of ElasticLogger
Returns
Cake\ElasticSearch\Datasource\Log\ElasticLogger
getIndex() ¶ 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\Index
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\LoggerInterface
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\SchemaCollection
isQueryLoggingEnabled() ¶ public
isQueryLoggingEnabled(): bool
Check if query logging is enabled.
Returns
bool
setCacher() ¶ public
setCacher(Psr\SimpleCache\CacheInterface $cacher): $this
Set a cacher.
Parameters
-
Psr\SimpleCache\CacheInterface
$cacher
Returns
$this
setLogger() ¶ public
setLogger(Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface $logger): $this
Sets a logger
Parameters
-
Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface
$logger Logger instance
Returns
$this