diff --git a/framework/yii/elasticsearch/ActiveRecord.php b/framework/yii/elasticsearch/ActiveRecord.php index 5f58a04..6a036cb 100644 --- a/framework/yii/elasticsearch/ActiveRecord.php +++ b/framework/yii/elasticsearch/ActiveRecord.php @@ -15,12 +15,29 @@ use yii\helpers\Inflector; use yii\helpers\Json; use yii\helpers\StringHelper; -// TODO handle optimistic lock - /** * ActiveRecord is the base class for classes representing relational data in terms of objects. * + * This class implements the ActiveRecord pattern for the fulltext search and data storage + * [elasticsearch](http://www.elasticsearch.org/). + * + * For defining a record a subclass should at least implement the [[attributes()]] method to define + * attributes. + * The primary key (the `_id` field in elasticsearch terms) is represented by `getId()` and `setId()`. + * + * The following is an example model called `Customer`: + * + * ```php + * class Customer extends \yii\elasticsearch\ActiveRecord + * { + * public function attributes() + * { + * return ['id', 'name', 'address', 'registration_date']; + * } + * } + * ``` * + * You may override [[index()]] and [[type()]] to define the index and type this record represents. * * @author Carsten Brandt * @since 2.0 diff --git a/framework/yii/elasticsearch/Cluster.php b/framework/yii/elasticsearch/Cluster.php new file mode 100644 index 0000000..fda4175 --- /dev/null +++ b/framework/yii/elasticsearch/Cluster.php @@ -0,0 +1,16 @@ + + */ + +namespace yii\elasticsearch; + + +use yii\base\Object; + +class Cluster extends Object +{ + // TODO implement http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster.html +} \ No newline at end of file diff --git a/framework/yii/elasticsearch/Connection.php b/framework/yii/elasticsearch/Connection.php index 73d7aad..46c1efb 100644 --- a/framework/yii/elasticsearch/Connection.php +++ b/framework/yii/elasticsearch/Connection.php @@ -34,6 +34,9 @@ class Connection extends Component ) ); + // http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html#_example_configuring_http_basic_auth + public $auth = []; + // TODO use timeouts /** * @var float timeout to use for connection to redis. If not set the timeout set in php.ini will be used: ini_get("default_socket_timeout") @@ -92,6 +95,9 @@ class Connection extends Component */ public function open() { + // TODO select one node to be the active one. + + foreach($this->nodes as $key => $node) { if (is_array($node)) { $this->nodes[$key] = new Node($node);