Method | Description | |
---|---|---|
arrayAttributes ( ) : string[] | A list of attributes that should be treated as array valued when retrieved through [[ActiveQuery::fields]]. | |
attributes ( ) : string[] | Returns the list of all attribute names of the model. | |
delete ( array $options = [] ) : integer | boolean | ||
deleteAll ( array $condition = [] ) : integer | Deletes rows in the table using the provided conditions. | |
find ( ) : |
||
findAll ( $condition ) | ||
findOne ( $condition ) | ||
get ( mixed $primaryKey, array $options = [] ) : static | null | Gets a record by its primary key. | |
getDb ( ) : |
Returns the database connection used by this AR class. | |
getHighlight ( ) : array | null | ||
getOldPrimaryKey ( $asArray = false ) | ||
getPrimaryKey ( $asArray = false ) | ||
getScore ( ) : float | ||
index ( ) : string | ||
insert ( boolean $runValidation = true, array $attributes = null, array $options = ['op_type' => 'create'] ) : boolean | Inserts a document into the associated index using the attribute values of this record. | |
instantiate ( array $row ) : static | Creates an active record instance. | |
mget ( array $primaryKeys, array $options = [] ) : array | Gets a list of records by its primary keys. | |
optimisticLock ( ) | This method has no effect in Elasticsearch ActiveRecord. | |
populateRecord ( |
||
primaryKey ( ) : string[] | This method defines the attribute that uniquely identifies a record. | |
setPrimaryKey ( mixed $value ) | Sets the primary key | |
type ( ) : string | ||
unlinkAll ( $name, $delete = false ) | Destroys the relationship in current model. | |
update ( boolean $runValidation = true, array $attributeNames = null, array $options = [] ) : integer | boolean | ||
updateAll ( array $attributes, array $condition = [] ) : integer | Updates all records whos primary keys are given. | |
updateAllCounters ( array $counters, array $condition = [] ) : integer | Updates all matching records using the provided counter changes and conditions. |
Method | Description | |
---|---|---|
primaryKeysByCondition ( array $condition ) : array | Performs a quick and highly efficient scroll/scan query to get the list of primary keys that satisfy the given condition. If condition is a list of primary keys (e.g.: ['_id' => ['1', '2', '3']]), the query is not performed for performance considerations. | |
updateInternal ( array $attributes = null, array $options = [] ) : integer | false |
public arrayAttributes ( ) : string[] | ||
return | string[] | list of attribute names. Must be a subset of [[attributes()]]. |
public attributes ( ) : string[] | ||
return | string[] | list of attribute names. |
public delete ( array $options = [] ) : integer | boolean | ||
$options | array | options given in this parameter are passed to elasticsearch as request URI parameters. These are among others: - `routing` define shard placement of this record. - `parent` by giving the primaryKey of another record this defines a parent-child relation - `timeout` timeout waiting for a shard to become available. - `replication` the replication type for the delete/index operation (sync or async). - `consistency` the write consistency of the index/delete operation. - `refresh` refresh the relevant primary and replica shards (not the whole index) immediately after the operation occurs, so that the updated document appears in search results immediately. Please refer to the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html) for more details on these options. The following parameters are Yii specific: - `optimistic_locking` set this to `true` to enable optimistic locking, avoid updating when the record has changed since it has been loaded from the database. Yii will set the `version` parameter to the value stored in [[version]]. See the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html#delete-versioning) for details. Make sure the record has been fetched with a [[version]] before. This is only the case for records fetched via [[get()]] and [[mget()]] by default. For normal queries, the `_version` field has to be fetched explicitly. |
return | integer | boolean | the number of rows deleted, or false if the deletion is unsuccessful for some reason. Note that it is possible the number of rows deleted is 0, even though the deletion execution is successful. |
public static find ( ) : |
||
return | the newly created [[ActiveQuery]] instance. |
public static get ( mixed $primaryKey, array $options = [] ) : static | null | ||
$primaryKey | mixed | the primaryKey value |
$options | array | options given in this parameter are passed to elasticsearch as request URI parameters. Please refer to the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html) for more details on these options. |
return | static | null | The record instance or null if it was not found. |
public static getDb ( ) : |
||
return | the database connection used by this AR class. |
public getHighlight ( ) : array | null | ||
return | array | null | A list of arrays with highlighted excerpts indexed by field names. |
public insert ( boolean $runValidation = true, array $attributes = null, array $options = ['op_type' => 'create'] ) : boolean | ||
$runValidation | boolean | whether to perform validation before saving the record. If the validation fails, the record will not be inserted into the database. |
$attributes | array | list of attributes that need to be saved. Defaults to null, meaning all attributes will be saved. |
$options | array | options given in this parameter are passed to elasticsearch as request URI parameters. These are among others: - `routing` define shard placement of this record. - `parent` by giving the primaryKey of another record this defines a parent-child relation - `timestamp` specifies the timestamp to store along with the document. Default is indexing time. Please refer to the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html) for more details on these options. By default the `op_type` is set to `create`. |
return | boolean | whether the attributes are valid and the record is inserted successfully. |
public static instantiate ( array $row ) : static | ||
$row | array | row data to be populated into the record. This array consists of the following keys: - `_source`: refers to the attributes of the record. - `_type`: the type this record is stored in. - `_index`: the index this record is stored in. |
return | static | the newly created active record |
public static mget ( array $primaryKeys, array $options = [] ) : array | ||
$primaryKeys | array | an array of primaryKey values |
$options | array | options given in this parameter are passed to elasticsearch as request URI parameters. Please refer to the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html) for more details on these options. |
return | array | The record instances, or empty array if nothing was found |
public optimisticLock ( ) |
public static populateRecord ( |
||
$record | the record to be populated. In most cases this will be an instance created by [[instantiate()]] beforehand. | |
$row | array | attribute values (name => value) |
public static primaryKey ( ) : string[] | ||
return | string[] | array of primary key attributes. Only the first element of the array will be used. |
protected static primaryKeysByCondition ( array $condition ) : array | ||
$condition | array | please refer to [[ActiveQuery::where()]] on how to specify this parameter |
return | array | primary keys that correspond to given conditions |
public setPrimaryKey ( mixed $value ) | ||
$value | mixed |
public unlinkAll ( $name, $delete = false ) |
public update ( boolean $runValidation = true, array $attributeNames = null, array $options = [] ) : integer | boolean | ||
$runValidation | boolean | whether to perform validation before saving the record. If the validation fails, the record will not be inserted into the database. |
$attributeNames | array | list of attribute names that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved. |
$options | array | options given in this parameter are passed to elasticsearch as request URI parameters. These are among others: - `routing` define shard placement of this record. - `parent` by giving the primaryKey of another record this defines a parent-child relation - `timeout` timeout waiting for a shard to become available. - `replication` the replication type for the delete/index operation (sync or async). - `consistency` the write consistency of the index/delete operation. - `refresh` refresh the relevant primary and replica shards (not the whole index) immediately after the operation occurs, so that the updated document appears in search results immediately. - `detect_noop` this parameter will become part of the request body and will prevent the index from getting updated when nothing has changed. Please refer to the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_parameters_3) for more details on these options. The following parameters are Yii specific: - `optimistic_locking` set this to `true` to enable optimistic locking, avoid updating when the record has changed since it has been loaded from the database. Yii will set the `version` parameter to the value stored in [[version]]. See the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html) for details. Make sure the record has been fetched with a [[version]] before. This is only the case for records fetched via [[get()]] and [[mget()]] by default. For normal queries, the `_version` field has to be fetched explicitly. |
return | integer | boolean | the number of rows affected, or false if validation fails or [[beforeSave()]] stops the updating process. |
public static updateAll ( array $attributes, array $condition = [] ) : integer | ||
$attributes | array | attribute values (name-value pairs) to be saved into the table |
$condition | array | the conditions that will be passed to the `where()` method when building the query. Please refer to [[ActiveQuery::where()]] on how to specify this parameter. |
return | integer | the number of rows updated |
public static updateAllCounters ( array $counters, array $condition = [] ) : integer | ||
$counters | array | the counters to be updated (attribute name => increment value). Use negative values if you want to decrement the counters. |
$condition | array | the conditions that will be passed to the `where()` method when building the query. Please refer to [[ActiveQuery::where()]] on how to specify this parameter. |
return | integer | the number of rows updated |
protected updateInternal ( array $attributes = null, array $options = [] ) : integer | false | ||
$attributes | array | attributes to update |
$options | array | options given in this parameter are passed to elasticsearch as request URI parameters. See [[update()]] for details. |
return | integer | false | the number of rows affected, or false if [[beforeSave()]] stops the updating process. |