Свойство | Тип | Описание | |
---|---|---|---|
$facets | facet search specifications. For example: php [ 'group_id', 'brand_id' => [ 'order' => ['COUNT(*)' => SORT_ASC], ], 'price' => [ 'select' => 'INTERVAL(price,200,400,600,800) AS price', 'order' => ['FACET()' => SORT_ASC], ], 'name_in_json' => [ 'select' => [new Expression('json_attr.name AS name_in_json')], ], ] You need to use Query::search method in order to fetch facet results. Note: if you specify custom select for the facet, ensure facet name has corresponding column inside it. | ||
$groupLimit | groups limit: to return (no more than) N top matches for each group. This option will take effect only if [[groupBy]] is set. | ||
$match | text, which should be searched in fulltext mode. This value will be composed into MATCH operator inside the WHERE clause. Note: this value will be processed by [[Connection::escapeMatchValue()]], if you need to compose complex match condition use [[Expression]], see Query::match for details. | ||
$options | per-query options in format: optionName => optionValue They will compose OPTION clause. This is a Sphinx specific extension that lets you control a number of per-query options. | ||
$showMeta | whether to automatically perform 'SHOW META' query against main one. You may set this value to be string or [[Expression]] instance, in this case its value will be used as 'LIKE' condition for 'SHOW META' statement. You need to use Query::search method in order to fetch 'meta' results. | ||
$snippetCallback | PHP callback, which should be used to fetch source data for the snippets. Such callback will receive array of query result rows as an argument and must return the array of snippet source strings in the order, which match one of incoming rows. For example: php $query = new Query(); $query->from('idx_item') ->match('pencil') ->snippetCallback(function ($rows) { $result = []; foreach ($rows as $row) { $result[] = file_get_contents('/path/to/index/files/' . $row['id'] . '.txt'); } return $result; }) ->all(); | ||
$snippetOptions | query options for the call snippet. | ||
$within | WITHIN GROUP ORDER BY clause. This is a Sphinx specific extension that lets you control how the best row within a group will to be selected. The possible value matches the [[orderBy]] one. |
Метод | Описание | |
---|---|---|
addFacets ( array $facets ) | Adds additional FACET part of the query. | |
addOptions ( array $options ) | Adds additional query options. | |
addWithin ( string | array $columns ) | Adds additional WITHIN GROUP ORDER BY columns to the query. | |
create ( |
Creates a new Query object and copies its property values from an existing one. | |
createCommand ( |
Creates a Sphinx command that can be used to execute this query. | |
facets ( array $facets ) | Sets FACET part of the query. | |
getConnection ( ) : |
||
groupLimit ( integer $limit ) | Sets groups limit: to return (no more than) N top matches for each group. | |
innerJoin ( $table, $on = '', $params = [] ) | ||
join ( $type, $table, $on = '', $params = [] ) | ||
leftJoin ( $table, $on = '', $params = [] ) | ||
match ( string | yii\db\Expression | |
Sets the fulltext query text. This text will be composed into MATCH operator inside the WHERE clause. | |
one ( $db = null ) | ||
options ( array $options ) | Sets the query options. | |
populate ( $rows ) | ||
rightJoin ( $table, $on = '', $params = [] ) | ||
search ( |
Executes the query and returns the complete search result including e.g. hits, facets. | |
setConnection ( |
||
showMeta ( boolean | string | yii\db\Expression $showMeta ) | Sets whether to automatically perform 'SHOW META' for the search query. | |
snippetCallback ( callable $callback ) | Sets the PHP callback, which should be used to retrieve the source data for the snippets building. | |
snippetOptions ( array $options ) | Sets the call snippets query options. | |
within ( string | array $columns ) | Sets the WITHIN GROUP ORDER BY part of the query. |
Метод | Описание | |
---|---|---|
callSnippets ( array $source ) : array | Builds a snippets from provided source data. | |
callSnippetsInternal ( array $source, string $from ) : array | Builds a snippets from provided source data by the given index. | |
defaultConnection ( ) : |
||
fillUpSnippets ( array $rows ) : array | |
Fills the query result rows with the snippets built from source determined by [[snippetCallback]] result. | |
queryScalar ( $selectExpression, $db ) |
public addOptions ( array $options ) | ||
$options | array | query options in format: optionName => optionValue |
public addWithin ( string | array $columns ) | ||
$columns | string | array | the columns (and the directions) to find best row within a group. Columns can be specified in either a string (e.g. "id ASC, name DESC") or an array (e.g. `['id' => Query::SORT_ASC, 'name' => Query::SORT_DESC]`). The method will automatically quote the column names unless a column contains some parenthesis (which means the column contains a DB expression). |
protected callSnippets ( array $source ) : array | ||
$source | array | the source data to extract a snippet from. |
Результат | array | snippets list. |
public static create ( |
||
$from | the source query object | |
Результат | the new Query object |
public createCommand ( |
||
$db | the Sphinx connection used to generate the SQL statement. If this parameter is not given, the `sphinx` application component will be used. | |
Результат | the created Sphinx command instance. |
protected defaultConnection ( ) : |
||
Результат | default connection value. |
protected fillUpSnippets ( array $rows ) : array | |
||
$rows | array | raw query result rows. |
Результат | array | |
query result rows with filled up snippets. |
public getConnection ( ) : |
||
Результат | Sphinx connection instance |
public groupLimit ( integer $limit ) | ||
$limit | integer | group limit. |
public setConnection ( |
||
$connection | Sphinx connection instance |
public snippetCallback ( callable $callback ) | ||
$callback | callable | PHP callback, which should be used to fetch source data for the snippets. |
public snippetOptions ( array $options ) | ||
$options | array | call snippet options in format: option_name => option_value |
public within ( string | array $columns ) | ||
$columns | string | array | the columns (and the directions) to find best row within a group. Columns can be specified in either a string (e.g. "id ASC, name DESC") or an array (e.g. `['id' => Query::SORT_ASC, 'name' => Query::SORT_DESC]`). The method will automatically quote the column names unless a column contains some parenthesis (which means the column contains a DB expression). |
public $facets |
public $groupLimit |
public $match |
public $options |
public $showMeta |
public $snippetCallback |