Class yii\elasticsearch\Command
Inheritance | yii\elasticsearch\Command » yii\base\Component » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-elasticsearch/blob/master/Command.php |
The Command class implements the API for accessing the Elasticsearch REST API.
Check the Elasticsearch guide for details on these commands.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$db | yii\elasticsearch\Connection | yii\elasticsearch\Command | |
$index | string|array | The indexes to execute the query on. | yii\elasticsearch\Command |
$options | array | Options to be appended to the query URL, such as "search_type" for search or "timeout" for delete | yii\elasticsearch\Command |
$queryParts | array | List of arrays or json strings that become parts of a query | yii\elasticsearch\Command |
$type | string|array | The types to execute the query on. | yii\elasticsearch\Command |
Public Methods
Property Details
The indexes to execute the query on. Defaults to null meaning all indexes
Options to be appended to the query URL, such as "search_type" for search or "timeout" for delete
List of arrays or json strings that become parts of a query
The types to execute the query on. Defaults to null meaning all types
Method Details
See also https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-adding.
public boolean addAlias ( $index, $alias, $aliasParameters = [] ) | ||
$index | ||
$alias | ||
$aliasParameters | array |
Runs alias manipulations.
If you want to add alias1 to index1 and remove alias2 from index2 you can use following commands: ~~~ $actions = [
['add' => ['index' => 'index1', 'alias' => 'alias1']],
['remove' => ['index' => 'index2', 'alias' => 'alias2']],
]; ~~~
See also https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#indices-aliases.
public boolean aliasActions ( array $actions ) | ||
$actions | array |
public boolean aliasExists ( $alias ) | ||
$alias | string |
public mixed clearIndexCache ( $index ) | ||
$index |
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html.
public mixed clearScroll ( $options = [] ) | ||
$options | array |
public mixed closeIndex ( $index ) | ||
$index |
Creates an index
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html.
public mixed createIndex ( $index, $configuration = null ) | ||
$index | ||
$configuration | array |
public mixed createTemplate ( $name, $pattern, $settings, $mappings, $order = 0 ) | ||
$name | ||
$pattern | ||
$settings | ||
$mappings | ||
$order | integer |
Deletes a document from the index
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html.
public mixed delete ( $index, $type, $id, $options = [] ) | ||
$index | ||
$type | ||
$id | ||
$options | array |
Deletes all indexes
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html.
public mixed deleteAllIndexes ( ) |
Sends a request to the delete by query
public mixed deleteByQuery ( $options = [] ) | ||
$options | array |
Deletes an index
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html.
public mixed deleteIndex ( $index ) | ||
$index |
public mixed deleteTemplate ( $name ) | ||
$name |
Gets a document from the index
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html.
public mixed exists ( $index, $type, $id ) | ||
$index | ||
$type | ||
$id |
public mixed flushIndex ( $index = '_all' ) | ||
$index |
Gets a document from the index
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html.
public mixed get ( $index, $type, $id, $options = [] ) | ||
$index | ||
$type | ||
$id | ||
$options | array |
See also https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-retrieving.
public array getAliasInfo ( ) |
See also https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-retrieving.
public array getIndexAliases ( $index ) | ||
$index | string |
See also https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-retrieving.
public array getIndexInfoByAlias ( $alias ) | ||
$alias | string |
public mixed getIndexRecoveryStats ( $index = '_all' ) | ||
$index |
public mixed getIndexStats ( $index = '_all' ) | ||
$index |
public array getIndexesByAlias ( $alias ) | ||
$alias | string |
public mixed getMapping ( $index = '_all', $type = null ) | ||
$index | string | |
$type | string |
Gets a documents _source from the index (>=v0.90.1)
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html#_source.
public mixed getSource ( $index, $type, $id ) | ||
$index | ||
$type | ||
$id |
public mixed getTemplate ( $name ) | ||
$name |
Checks whether an index exists
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html.
public mixed indexExists ( $index ) | ||
$index |
Inserts a document into an index
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html.
public mixed insert ( $index, $type, $data, $id = null, $options = [] ) | ||
$index | string | |
$type | string | |
$data | string|array | Json string or array of data to store |
$id | null | The documents id. If not specified Id will be automatically chosen |
$options | array |
Gets multiple documents from the index
TODO allow specifying type and index + fields
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html.
public mixed mget ( $index, $type, $ids, $options = [] ) | ||
$index | ||
$type | ||
$ids | ||
$options | array |
public mixed openIndex ( $index ) | ||
$index |
public mixed refreshIndex ( $index ) | ||
$index |
public boolean removeAlias ( $index, $alias ) | ||
$index | string | |
$alias | string |
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html.
public mixed scroll ( $options = [] ) | ||
$options | array |
Sends a request to the _search API and returns the result
public mixed search ( $options = [] ) | ||
$options | array |
public mixed setMapping ( $index, $type, $mapping, $options = [] ) | ||
$index | string | |
$type | string | |
$mapping | string|array | |
$options | array |
Sends a suggest request to the _search API and returns the result
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html.
public mixed suggest ( $suggester, $options = [] ) | ||
$suggester | string|array | The suggester body |
$options | array |
public mixed typeExists ( $index, $type ) | ||
$index | ||
$type |
Updates a document
See also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html.
public mixed update ( $index, $type, $id, $data, $options = [] ) | ||
$index | ||
$type | ||
$id | ||
$data | ||
$options | array |
Define new analyzers for the index.
For example if content analyzer hasn’t been defined on "myindex" yet you can use the following commands to add it:
$setting = [
'analysis' => [
'analyzer' => [
'ngram_analyzer_with_filter' => [
'tokenizer' => 'ngram_tokenizer',
'filter' => 'lowercase, snowball'
],
],
'tokenizer' => [
'ngram_tokenizer' => [
'type' => 'nGram',
'min_gram' => 3,
'max_gram' => 10,
'token_chars' => ['letter', 'digit', 'whitespace', 'punctuation', 'symbol']
],
],
]
];
$elasticQuery->createCommand()->updateAnalyzers('myindex', $setting);
public mixed updateAnalyzers ( $index, $setting, $options = [] ) | ||
$index | string | |
$setting | string|array | |
$options | array | URL options |
Change specific index level settings in real time.
Note that update analyzers required to \yii\elasticsearch\close() the index first and \yii\elasticsearch\open() it after the changes are made, use updateAnalyzers() for it.
See also http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-update-settings.html.
public mixed updateSettings ( $index, $setting, $options = [] ) | ||
$index | string | |
$setting | string|array | |
$options | array | URL options |