Class yii\elasticsearch\Command
Inheritance | yii\elasticsearch\Command » yii\base\Component » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0 |
The Command class implements the API for accessing the elasticsearch REST API.
Check the elasticsearch guide for details on these commands.
Public Properties
隐藏继承的属性 Hide inherited properties
属性Property | 类型 Type | 简介 Description | 定义在 Defined By |
---|---|---|---|
$aliasInfo | array | yii\elasticsearch\Command | |
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component | yii\base\Component |
$db | yii\elasticsearch\Connection | yii\elasticsearch\Command | |
$index | string|array | The indexes to execute the query on. | yii\elasticsearch\Command |
$indexStatus | mixed | yii\elasticsearch\Command | |
$mapping | mixed | 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
隐藏继承的方法 Hide inherited 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
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']],
];
请参阅 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 |
public mixed clearScroll ( $options = [] ) | ||
$options | array |
public mixed closeIndex ( $index ) | ||
$index |
Creates an index
请参阅 http://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
请参阅 http://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
请参阅 http://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
请参阅 http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html.
public mixed deleteIndex ( $index ) | ||
$index |
public mixed deleteMapping ( $index, $type ) | ||
$index | ||
$type |
public mixed deleteTemplate ( $name ) | ||
$name |
Gets a document from the index
请参阅 http://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
请参阅 http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html.
public mixed get ( $index, $type, $id, $options = [] ) | ||
$index | ||
$type | ||
$id | ||
$options | array |
请参阅 https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-retrieving.
public array getAliasInfo ( ) |
请参阅 https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-retrieving.
public array getIndexAliases ( $index ) | ||
$index | string |
请参阅 https://www.elastic.co/guide/en/elasticsearch/reference/2.0/indices-aliases.html#alias-retrieving.
public array getIndexInfoByAlias ( $alias ) | ||
$alias | string |
public mixed getIndexStatus ( $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)
请参阅 http://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
请参阅 http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html.
public mixed indexExists ( $index ) | ||
$index |
Inserts a document into an index
请参阅 http://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
请参阅 http://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 |
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 request to the _suggest API and returns the result
请参阅 http://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
请参阅 http://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.
请参阅 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 |