include/SugarSearchEngine/Elastic/Elastica/Query.php
Elastica query object
Creates different types of queries
- Author
- Nicolas Ruflin
- Category
- Xodoa
- Link
- http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/
- Package
- Elastica
\Elastica_Query
Elastica query object
Creates different types of queries
- Parent(s)
- \Elastica_Param
- Author
- Nicolas Ruflin
- Category
- Xodoa
- Link
- http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/
Properties
$_rawParams= 'array()'
array()
Details- Type
- n/a
- Inherited_from
- \Elastica_Param::$$_rawParams
Methods
__construct(
array | \Elastica_Query_Abstract $query
=
null
)
:
void
Creates a query object
Name | Type | Description |
---|---|---|
$query | array | \Elastica_Query_Abstract | OPTIONAL Query object (default = null) |
_setRawParam(
string $key, mixed $value
)
:
\Elastica_Param
Name | Type | Description |
---|---|---|
$key | string | |
$value | mixed |
Type | Description |
---|---|
\Elastica_Param |
addFacet(
\Elastica_Facet_Abstract $facet
)
:
\Elastica_Query
Adds a Facet to the query
Name | Type | Description |
---|---|---|
$facet | \Elastica_Facet_Abstract | Facet object |
Type | Description |
---|---|
\Elastica_Query | Query object |
addHighlight(
mixed $highlight
)
:
\Elastica_Query
Adds a highlight argument
Name | Type | Description |
---|---|---|
$highlight | mixed | Add highlight argument |
Type | Description |
---|---|
\Elastica_Query | Query object |
addParam(
string $key, mixed $value
)
:
\Elastica_Param
This function can be used to add an array of params
Name | Type | Description |
---|---|---|
$key | string | Param key |
$value | mixed | Value to set |
Type | Description |
---|---|
\Elastica_Param |
addSort(
mixed $sort
)
:
\Elastica_Query
Adds a sort param to the query
Name | Type | Description |
---|---|---|
$sort | mixed | Sort parameter |
Type | Description |
---|---|
\Elastica_Query | Query object |
create(
mixed $query
)
:
\Elastica_Query
Transforms a string or an array to a query object
If query is empty,
Name | Type | Description |
---|---|---|
$query | mixed |
Type | Description |
---|---|
\Elastica_Query |
getParam(
string $key
)
:
mixed
Name | Type | Description |
---|---|---|
$key | string | Key to return |
Type | Description |
---|---|
mixed | Key value |
Exception | Description |
---|---|
\Elastica_Exception_Invalid | If requested key is not set |
setExplain(
bool $explain
=
true
)
:
\Elastica_Query
Enables explain on the query
Name | Type | Description |
---|---|---|
$explain | bool | OPTIONAL Enabled or disable explain (default = true) |
Type | Description |
---|---|
\Elastica_Query | Current object |
setFacets(
array $facets
)
:
\Elastica_Query
Sets all facets for this query object. Replaces existing facets
Name | Type | Description |
---|---|---|
$facets | array | List of facet objects |
Type | Description |
---|---|
\Elastica_Query | Query object |
setFields(
array $fields
)
:
\Elastica_Query
Sets the fields to be returned by the search
Name | Type | Description |
---|---|---|
$fields | array | Fields to be returne |
Type | Description |
---|---|
\Elastica_Query | Current object |
setFilter(
\Elastica_Filter_Abstract $filter
)
:
\Elastica_Query
Name | Type | Description |
---|---|---|
$filter | \Elastica_Filter_Abstract | Filter object |
Type | Description |
---|---|
\Elastica_Query | Current object |
setFrom(
int $from
)
:
\Elastica_Query
Sets the start from which the search results should be returned
Name | Type | Description |
---|---|---|
$from | int |
Type | Description |
---|---|
\Elastica_Query | Query object |
setHighlight(
array $highlightArgs
)
:
\Elastica_Query
Sets highlight arguments for the query
Name | Type | Description |
---|---|---|
$highlightArgs | array | Set all highlight arguments |
Type | Description |
---|---|
\Elastica_Query | Query object |
setLimit(
int $limit
=
10
)
:
\Elastica_Query
Sets maximum number of results for this query
Setting the limit to 0, means no limit
Name | Type | Description |
---|---|---|
$limit | int | OPTIONAL Maximal number of results for query (default = 10) |
Type | Description |
---|---|
\Elastica_Query | Query object |
setMinScore(
int | double $minScore
)
:
\Elastica_Query
Allows filtering of documents based on a minimum score
Name | Type | Description |
---|---|---|
$minScore | int | double | Minimum score to filter documents by |
Type | Description |
---|---|
\Elastica_Query | Query object |
setParam(
string $key, mixed $value
)
:
void
Name | Type | Description |
---|---|---|
$key | string | Key to set |
$value | mixed | Key Value |
setParams(
array $params
)
:
\Elastica_Param
Name | Type | Description |
---|---|---|
$params | array | Parameter list |
Type | Description |
---|---|
\Elastica_Param |
setQuery(
\Elastica_Query_Abstract $query
)
:
\Elastica_Query
Sets the query
Name | Type | Description |
---|---|---|
$query | \Elastica_Query_Abstract | Query object |
Type | Description |
---|---|
\Elastica_Query | Query object |
setRawQuery(
array $query
)
:
\Elastica_Query
Sets query as raw array. Will overwrite all already set arguments
Name | Type | Description |
---|---|---|
$query | array | Query array |
Type | Description |
---|---|
\Elastica_Query | Query object |
setScriptFields(
array $scriptFields
)
:
\Elastica_Query
Set script fields
Name | Type | Description |
---|---|---|
$scriptFields | array | Script fields |
Type | Description |
---|---|
\Elastica_Query | Current object |
setSize(
int $limit
=
10
)
:
\Elastica_Query
Alias for setLimit
Name | Type | Description |
---|---|---|
$limit | int | OPTIONAL Maximal number of results for query (default = 10) |
Type | Description |
---|---|
\Elastica_Query | Query object |
setSort(
array $sortArgs
)
:
\Elastica_Query
Sets sort arguments for the query Replaces existing values
Name | Type | Description |
---|---|---|
$sortArgs | array | Sorting arguments |
Type | Description |
---|---|
\Elastica_Query | Query object |
setVersion(
bool $version
=
true
)
:
\Elastica_Query
Enables version on the query
Name | Type | Description |
---|---|---|
$version | bool | OPTIONAL Enabled or disable version (default = true) |
Type | Description |
---|---|
\Elastica_Query | Current object |