Property | Type | Description | |
---|---|---|---|
$aggregations | List of aggregations to add to this query. | ||
$fields | the fields being retrieved from the documents. For example, ['id', 'name']. If not set, this option will not be applied to the query and no fields will be returned. In this case the _source field will be returned by default which can be configured using [[source]]. Setting this to an empty array will result in no fields being retrieved, which means that only the primaryKey of a record will be available in the result. For each field you may also add an array representing a [script field]. Example: php $query->fields = [ 'id', 'name', 'value_times_two' => [ 'script' => "doc['my_field_name'].value * 2", ], 'value_times_factor' => [ 'script' => "doc['my_field_name'].value * factor", 'params' => [ 'factor' => 2.0 ], ], ] > Note: Field values are [always returned as arrays] even if they only have one value. [always returned as arrays]: http://www.elastic.co/guide/en/elasticsearch/reference/1.x/_return_values.html#_return_values [script field]: http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html | ||
$filter | The filter part of this search query. This is an array or json string that follows the format of the elasticsearch Query DSL. | ||
$highlight | The highlight part of this search query. This is an array that allows to highlight search results on one or more fields. | ||
$index | The index to retrieve data from. This can be a string representing a single index or a an array of multiple indexes. If this is not set, indexes are being queried. | ||
$minScore | Exclude documents which have a _score less than the minimum specified in min_score | ||
$options | list of options that will passed to commands created by this query. | ||
$postFilter | The post_filter part of the search query for differentially filter search results and aggregations. | ||
$query | The query part of this search query. This is an array or json string that follows the format of the elasticsearch Query DSL. | ||
$source | this option controls how the _source field is returned from the documents. For example, ['id', 'name'] means that only the id and name field should be returned from _source. If not set, it means retrieving the full _source field unless [[fields]] are specified. Setting this option to false will disable return of the _source field, this means that only the primaryKey of a record will be available in the result. | ||
$stats | the 'stats' part of the query. An array of groups to maintain a statistics aggregation for. | ||
$suggest | list of suggesters to add to this query. | ||
$timeout | A search timeout, bounding the search request to be executed within the specified time value and bail with the hits accumulated up to that point when expired. Defaults to no timeout. | ||
$type | The type to retrieve data from. This can be a string representing a single type or a an array of multiple types. If this is not set, all types are being queried. |
Method | Description | |
---|---|---|
addAgg ( string $name, string $type, string | array $options ) | ||
addAggregate ( string $name, string | array $options ) | Adds an aggregation to this query. Supports nested aggregations. | |
addAggregation ( string $name, string $type, string | array $options ) | ||
addOptions ( array $options ) | Adds more options, overwriting existing options. | |
addSuggester ( string $name, string | array $definition ) | Adds a suggester to this query. | |
all ( |
Executes the query and returns all results as an array. | |
batch ( string $scrollWindow = '1m', |
Starts a batch query. | |
column ( string $field, |
Executes the query and returns the first column of the result. | |
count ( string $q = '*', |
Returns the number of records. | |
createCommand ( |
Creates a DB command that can be used to execute this query. | |
delete ( |
Executes the query and deletes all matching documents. | |
each ( string $scrollWindow = '1m', |
Starts a batch query and retrieves data row by row. | |
exists ( |
Returns a value indicating whether the query result contains any row of data. | |
fields ( array $fields ) | Sets the fields to retrieve from the documents. | |
filter ( string $filter ) | Sets the filter part of this search query. | |
from ( string | array $index, string | array $type = null ) | Sets the index and type to retrieve documents from. | |
highlight ( array $highlight ) | Sets a highlight parameters to retrieve from the documents. | |
init ( ) | ||
minScore ( float $minScore ) : static | ||
one ( |
Executes the query and returns a single row of result. | |
options ( array $options ) | Sets the options to be passed to the command created by this query. | |
populate ( array $rows ) : array | Converts the raw query results into the format as specified by this query. | |
postFilter ( string | array $filter ) | Set the post_filter part of the search query. | |
query ( string $query ) | Sets the querypart of this search query. | |
scalar ( string $field, |
Returns the query result as a scalar value. | |
search ( |
Executes the query and returns the complete search result including e.g. hits, facets, totalCount. | |
source ( array $source ) | Sets the source filtering, specifying how the _source field of the document should be returned. | |
stats ( array $groups ) | Adds a 'stats' part to the query. | |
timeout ( integer $timeout ) | Sets the search timeout. |
public addOptions ( array $options ) | ||
$options | array | the options to be added. |
public batch ( string $scrollWindow = '1m', |
||
$scrollWindow | string | how long Elasticsearch should keep the search context alive, in [time units](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units) |
$db | the database connection. If not set, the `elasticsearch` application component will be used. | |
return | the batch query result. It implements the [[\Iterator]] interface and can be traversed to retrieve the data in batches. |
public column ( string $field, |
||
$field | string | the field to query over |
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
return | array | the first column of the query result. An empty array is returned if the query results in nothing. |
public count ( string $q = '*', |
||
$q | string | the COUNT expression. This parameter is ignored by this implementation. |
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
return | integer | number of records |
public createCommand ( |
||
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
return | the created DB command instance. |
public delete ( |
||
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
$options | array | The options given with this query. |
return | array | the query results. |
public each ( string $scrollWindow = '1m', |
||
$scrollWindow | string | how long Elasticsearch should keep the search context alive, in [time units](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units) |
$db | the database connection. If not set, the `elasticsearch` application component will be used. | |
return | the batch query result. It implements the [[\Iterator]] interface and can be traversed to retrieve the data in batches. |
public from ( string | array $index, string | array $type = null ) | ||
$index | string | array | The index to retrieve data from. This can be a string representing a single index or a an array of multiple indexes. If this is `null` it means that all indexes are being queried. |
$type | string | array | The type to retrieve data from. This can be a string representing a single type or a an array of multiple types. If this is `null` it means that all types are being queried. |
public one ( |
||
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
return | array | boolean | the first row (in terms of an array) of the query result. False is returned if the query results in nothing. |
public postFilter ( string | array $filter ) | ||
$filter | string | array |
public scalar ( string $field, |
||
$field | string | name of the attribute to select |
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
return | string | the value of the specified attribute in the first record of the query result. Null is returned if the query result is empty or the field does not exist. |
public search ( |
||
$db | the database connection used to execute the query. If this parameter is not given, the `elasticsearch` application component will be used. | |
$options | array | The options given with this query. Possible options are: - [routing](http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html#search-routing) - [search_type](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html) |
return | array | the query results. |
public $fields |
public $filter |
public $highlight |
public $index |
public $minScore |
public $options |
public $postFilter |
public $query |
public $source |
public $stats |
public $timeout |