PHP Class yii\elasticsearch\Command

Check the elasticsearch guide for details on these commands.
Since: 2.0
Author: Carsten Brandt ([email protected])
Inheritance: extends yii\base\Component
Datei anzeigen Open project: yiisoft/yii2-elasticsearch Class Usage Examples

Public Properties

Property Type Description
$db Connection
$index the indexes to execute the query on. Defaults to null meaning all indexes
$options options to be appended to the query URL, such as "search_type" for search or "timeout" for delete
$queryParts list of arrays or json strings that become parts of a query
$type the types to execute the query on. Defaults to null meaning all types

Public Methods

Method Description
clearIndexCache ( $index ) : mixed
clearScroll ( array $options = [] ) : mixed
closeIndex ( $index ) : mixed
createIndex ( $index, array $configuration = null ) : mixed creates an index
createTemplate ( $name, $pattern, $settings, $mappings, integer $order ) : mixed
delete ( $index, $type, $id, array $options = [] ) : mixed deletes a document from the index
deleteAllIndexes ( ) : mixed deletes all indexes
deleteByQuery ( array $options = [] ) : mixed Sends a request to the delete by query
deleteIndex ( $index ) : mixed deletes an index
deleteMapping ( $index, $type ) : mixed
deleteTemplate ( $name ) : mixed
exists ( $index, $type, $id ) : mixed gets a document from the index
flushIndex ( $index = '_all' ) : mixed
get ( $index, $type, $id, array $options = [] ) : mixed gets a document from the index
getIndexStatus ( $index = '_all' ) : mixed
getMapping ( string $index = '_all', string $type = null ) : mixed
getSource ( $index, $type, $id ) : mixed gets a documents _source from the index (>=v0.90.1)
getTemplate ( $name ) : mixed
indexExists ( $index ) : mixed checks whether an index exists
insert ( string $index, string $type, string | array $data, null $id = null, array $options = [] ) : mixed Inserts a document into an index
mget ( $index, $type, $ids, array $options = [] ) : mixed gets multiple documents from the index
openIndex ( $index ) : mixed
refreshIndex ( $index ) : mixed
scroll ( array $options = [] ) : mixed
search ( array $options = [] ) : mixed Sends a request to the _search API and returns the result
setMapping ( string $index, string $type, string | array $mapping, array $options = [] ) : mixed
suggest ( string | array $suggester, array $options = [] ) : mixed Sends a request to the _suggest API and returns the result
typeExists ( $index, $type ) : mixed
update ( $index, $type, $id, $data, array $options = [] ) : mixed updates a document
updateAnalyzers ( string $index, string | array $setting, array $options = [] ) : mixed Define new analyzers for the index.
updateSettings ( string $index, string | array $setting, array $options = [] ) : mixed Change specific index level settings in real time.

Method Details

clearIndexCache() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html
public clearIndexCache ( $index ) : mixed
$index
return mixed

clearScroll() public method

See also: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
Since: 2.0.4
public clearScroll ( array $options = [] ) : mixed
$options array
return mixed

closeIndex() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
public closeIndex ( $index ) : mixed
$index
return mixed

createIndex() public method

creates an index
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
public createIndex ( $index, array $configuration = null ) : mixed
$index
$configuration array
return mixed

createTemplate() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
public createTemplate ( $name, $pattern, $settings, $mappings, integer $order ) : mixed
$name
$pattern
$settings
$mappings
$order integer
return mixed

delete() public method

deletes a document from the index
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
public delete ( $index, $type, $id, array $options = [] ) : mixed
$index
$type
$id
$options array
return mixed

deleteAllIndexes() public method

deletes all indexes
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
public deleteAllIndexes ( ) : mixed
return mixed

deleteByQuery() public method

Sends a request to the delete by query
public deleteByQuery ( array $options = [] ) : mixed
$options array
return mixed

deleteIndex() public method

deletes an index
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
public deleteIndex ( $index ) : mixed
$index
return mixed

deleteMapping() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
public deleteMapping ( $index, $type ) : mixed
$index
$type
return mixed

deleteTemplate() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
public deleteTemplate ( $name ) : mixed
$name
return mixed

exists() public method

gets a document from the index
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
public exists ( $index, $type, $id ) : mixed
$index
$type
$id
return mixed

flushIndex() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html
public flushIndex ( $index = '_all' ) : mixed
$index
return mixed

get() public method

gets a document from the index
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
public get ( $index, $type, $id, array $options = [] ) : mixed
$index
$type
$id
$options array
return mixed

getIndexStatus() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html
public getIndexStatus ( $index = '_all' ) : mixed
$index
return mixed

getMapping() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html
public getMapping ( string $index = '_all', string $type = null ) : mixed
$index string
$type string
return mixed

getSource() public method

gets a documents _source from the index (>=v0.90.1)
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html#_source
public getSource ( $index, $type, $id ) : mixed
$index
$type
$id
return mixed

getTemplate() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
public getTemplate ( $name ) : mixed
$name
return mixed

indexExists() public method

checks whether an index exists
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html
public indexExists ( $index ) : mixed
$index
return mixed

insert() public method

Inserts a document into an index
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
public insert ( string $index, string $type, string | array $data, null $id = null, array $options = [] ) : mixed
$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
return mixed

mget() public method

TODO allow specifying type and index + fields
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html
public mget ( $index, $type, $ids, array $options = [] ) : mixed
$index
$type
$ids
$options array
return mixed

openIndex() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
public openIndex ( $index ) : mixed
$index
return mixed

refreshIndex() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html
public refreshIndex ( $index ) : mixed
$index
return mixed

scroll() public method

See also: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
Since: 2.0.4
public scroll ( array $options = [] ) : mixed
$options array
return mixed

setMapping() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
public setMapping ( string $index, string $type, string | array $mapping, array $options = [] ) : mixed
$index string
$type string
$mapping string | array
$options array
return mixed

suggest() public method

Sends a request to the _suggest API and returns the result
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html
public suggest ( string | array $suggester, array $options = [] ) : mixed
$suggester string | array the suggester body
$options array
return mixed

typeExists() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html
public typeExists ( $index, $type ) : mixed
$index
$type
return mixed

update() public method

updates a document
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
public update ( $index, $type, $id, $data, array $options = [] ) : mixed
$index
$type
$id
$options array
return mixed

updateAnalyzers() public method

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); ~~~
See also: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html#update-settings-analysis
Since: 2.0.4
public updateAnalyzers ( string $index, string | array $setting, array $options = [] ) : mixed
$index string
$setting string | array
$options array URL options
return mixed

updateSettings() public method

Note that update analyzers required to [[close()]] the index first and [[open()]] it after the changes are made, use Command::updateAnalyzers for it.
See also: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-update-settings.html
Since: 2.0.4
public updateSettings ( string $index, string | array $setting, array $options = [] ) : mixed
$index string
$setting string | array
$options array URL options
return mixed

Property Details

$db public_oe property

public Connection,yii\elasticsearch $db
return Connection

$index public_oe property

the indexes to execute the query on. Defaults to null meaning all indexes
See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-multi-index-type
public $index

$options public_oe property

options to be appended to the query URL, such as "search_type" for search or "timeout" for delete
public $options

$queryParts public_oe property

list of arrays or json strings that become parts of a query
public $queryParts

$type public_oe property

the types to execute the query on. Defaults to null meaning all types
public $type