CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C Elastic Search 4.x API

  • Project:
    • Elastic Search
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 4.x
      • 4.x
      • 3.x
      • 2.x

Namespaces

  • Cake\ElasticSearch
    • Association
    • Datasource
      • Log
    • Exception
    • Rule
    • TestSuite
    • View

Class Connection

Namespace: Cake\ElasticSearch\Datasource

Constants

  • string
    ROLE_READ ¶
    'read'
  • string
    ROLE_WRITE ¶
    'write'

    Compatibility shim for ConnectionInterface

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)

config() ¶ public

config(): array

Get the config data for this connection.

Returns
array

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.

disableQueryLogging() ¶ public

disableQueryLogging(): $this

Disable query logging

Returns
$this

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
\Cake\Datasource\ConnectionInterface::getDriver()

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\QueryLogger|Psr\Log\LoggerInterface $logger): $this

Sets a logger

Parameters
Cake\Database\Log\QueryLogger|Psr\Log\LoggerInterface $logger

Logger instance

Returns
$this

Property Detail

$_client ¶ protected

Elastica client instance

Type
ElasticaClient

$_esLogger ¶ protected

Instance of ElasticLogger

Type
ElasticLogger

$_logger ¶ protected

Logger object instance.

Type
QueryLogger|LoggerInterface

$cacher ¶ protected

Type
CacheInterface

$configName ¶ protected

The connection name in the connection manager.

Type
string

$logQueries ¶ protected

Whether or not query logging is enabled.

Type
bool
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs